January 31, 2016 Night

Good evening. Currently overcast and 50 degrees in Delmar. Tonight will have a slight chance of showers after 3am. Mostly cloudy, with a low around 40. South wind around 9 mph. Chance of precipitation is 20%. Not a bad end to January for sure.

Tonight is the Last Quarter Moon with 46% illuminated. It will rise at 12:37 am. Tomorrow’s sunrise will be at 7:08 am with first light at 6:39 am, which is 2 minutes earlier then today. Certainly on Tuesday when the clouds are expected to break, we’ll have a brighter morning.

We’ve closed out January 2016. Warm, long summer nights can’t be that far around the corner. Good night.

January 31, 2016 Evening

Good evening. Currently mostly cloudy and 50 degrees in Westerlo. Tonight will have a slight chance of showers after 3am. Mostly cloudy, with a low around 42. South wind around 8 mph. Chance of precipitation is 20%. The clouds weren’t nice today but it was mild. Tonight is the Last Quarter Moon with 46% illuminated. It will rise at 12:38 am.

Monday will have a chance of showers, mainly before 2pm. Mostly cloudy, with a high near 50. South wind 8 to 10 mph becoming northwest in the afternoon. Chance of precipitation is 30%. New precipitation amounts of less than a tenth of an inch possible.

I checked the oil in my truck today and it was low. I wasn’t happy about that, but I realized I hadn’t checked the oil in a while, and it’s been 10,000 miles since the last oil change (that I thought about doing last weekend but never happened). I meant to check it but it didn’t happen. I wasn’t happy about the low oil, as it means the engine is burning oil, but then again, it’s been 10,000 miles, and I haven’t added any since then.

So I go to Walmart and buy a quart of oil. I decided to add oil in the parking lot, so I don’t risk driving on low oil. I didn’t have a funnel with but I poured it in carefully. But I managed to spill some on the manifold in the process. I get to the next stoplight and smoke starts pouring out from under the hood. I find a place safe in a parking lot to pull off, open the hood, and mop up the oil I spilled on the manifold. It smoked a little more, but a few minutes later it was all burnt off it. Everything seems fine now that it cooled down.

Needless to say, I’m not happy about the oil consumption. But hopefully I’ll get a least a few more years out of the truck without any major repairs. And if it consumes a quart of oil every 10,000 miles, it’s not the end of the world. I just got to check it more frequently and not leave it multiple months without checking. But with the battery issue in December and being busy in November, somehow it just slipped my mind (I put on like 3,000-4,000 miles on my October trip). The truck won’t last forever, but that’s fine, it’s hardly been a perfect vehicle to start out with.

But this kind of wrecked my afternoon.

January 31, 2016 Morning

Good morning! January is coming to an end! It is currently overcast and 40 degrees in Delmar. The sun is occasionally peaking out of the clouds but no blue sky is to be seen Today will be mostly cloudy, with a high near 48. South wind around 7 mph. Maybe a chance of seeing a little blue sky before the sun sets tonight?

Sunset will be at 5:07 pm with twilight at 5:37 pm which is one minute and 19 seconds later then yesterday. Tonight is the Last Quarter Moon with 46% illuminated. It will rise at 12:38 am. Past my bedtime, so it will be pretty dark night. The New Moon is on February 8. I believe the full moon is Monday, February 22, but don’t quote me on that as I don’t have the moon calendar in front of me.

There are 2 months, 1 day until April Fools Day. Trout Season starts on that day too. I hear a rumor that the state budget is due that day too but it probably won’t happen on-time because they had to schedule an easter holiday right before April Fools day. Usually April Fools Day demarcates hardcore winter with nicer weather for camping. I ain’t no fool, but I like April Fools Day.

This day in 1990, the first McDonald’s in the Soviet Union opens in Moscow. The important part of this historical tidbit: β€œDid they offer buck coffee?” It really annoys me when local McDonald’s don’t offer coffee for a buck. It keeps you alive on the road. Most other McDonald’s food is pretty overpriced and gross. I’ll just buy a bag of chips at the local grocery store to hold me over while I drive where I need to go. I’m really not a fan of restaurant food. I’d prefer to cook it over a fire or in the woods.

Today I’m going to play with maps a little more then run to Walmart to pick up a few things I couldn’t find at Shoprite, then possibly to the car wash to wash off more salt off the truck. Then I’m thinking of heading down to Hannacroix Preserve before heading to my parents house for Sunday dinner.

Last night I put together a lot of pretty interesting maps for the next week or two, now that I’m done with QGIS scripting for a while. It can be tough to come up with new data and find interesting things to map, but I think have some interesting new maps. They include a bunch of state land maps, Albany City School Bond vote (including a Cartogram), Solid Waste Facilities, and an Updated Wilderness and State Forest Overview Maps.

Fun stuff.

Code Scrap for Exporting a Map to a Raster PDF

I don’t like the vector Adobe Acrobat PDF that Quantum GIS exports by default if you don’t specifically check “Export as Raster” in the Composer View. It’s true that Vector PDF is a higher quality, but the files are much larger and slower loading. A 300 DPI raster PDF file will suffice for most printing needs.

I struggled for a number of days to figure out the best way to export a Raster PDF from Quantum GIS with PyQGIS. I ended up giving up, preferring to just export a high-resolution JPEG and convert the JPEG to a Adobe PDF using ImageMagick’s convert command. It gave me much smaller PDF files due to higher compression then what you get through the PDF export built into QGIS’s Composers with the “Export as Raster” checked.

When you use printPageAsRaster(0), all settings related to resolution are preserved in the exported file (such as 300 DPI format and 8×10 page size), so ImageMagick automatically converts it over.

You don’t have to include all the libraries that are listed below, I was lazy, and I needed all of them for my map automation plugin, so I left them in. You should remove the ones you don’t use. Don’t forget to change the composer name from Horizontal to the composer you use, and adjust the output paths accordingly.

It may not be elegant, but it works well. This is my solution, it may not be yours.

from PyQt4.QtCore import QSettings, QTranslator, qVersion, QCoreApplication,QFileInfo,QSizeF
from PyQt4.QtGui import QAction, QIcon, QPrinter,QPainter
from os import sys 

composerId = 0
composers = iface.activeComposers()
for item in composers:
	if item.composerWindow().windowTitle() == 'Horizontal':
		break
	composerId += 1

c = composers[composerId].composition()

image = c.printPageAsRaster(0)
image.save("/tmp/"+QgsProject.instance().title()+".jpg", "jpg")
os.system('convert "/tmp/'+QgsProject.instance().title()+'.jpg" "/tmp/'+QgsProject.instance().title()+'.pdf"')

Evening Down in the Ravine

A follow up to yesterday's post about Vector export of QGIS Composers using PyQGIS. This does the export as a Raster PDF, for much smaller files but with the same or better quality.