January 30, 2016 Night

Good evening. Currently overcast and 37 degrees in Delmar. Tonight will be mostly cloudy, with a low around 32. South wind 6 to 13 mph. Mild temperatures for sure but the breeze will keep it from feeling too warm.

Tonight we will have a Waining Gibbous Moon with 53% illuminated. It will rise at 11:40 pm. Even if your up late it may be difficult to see with the clouds. Tomorrow’s sunrise will be at 7:10 am with first light at 6:40 am, which is 2 minutes earlier then today. Certainly come Monday, it will make getting up easier assuming it’s not gray and cloudy out like most mornings.

Tonight I went to Five Rivers for a walk and to watch the sunset, although by the time I got there the sun was pretty much behind the Heldeberg Mountains. So be it. It’s my fault for not getting an earlier start.

Picked up some groceries, cranked out some more maps. Some are new, others are updated versions of old ones. Went for my evening walk. And now I’m off to bed.

I hope you had a good day. Sleep well!

Darn TV Advertising

Monday I’m calling Time Warner Cable and Verizon to tell them I don’t own a television and I don’t want home Internet. They got to stop mailing me. I get at least one glossy card a day from both of them. For eight freaking years. It’s annoying and such a waste of paper.

Maybe it’s because I grew up without a television set, I have zero interest in those kinds of services. Especially now with 3G Smartphone, I can’t imagine why I would need such a service. I get email, social media, and other services in my phone. When I need something data intensive I can walk or drive to the public library. Even if eventually when I move out of the city to an off-grid cabin, I will still be able to stop by a library after work for data intensive tasks.

I just don’t really understand the appeal of those big television sets. It’s just so many bright and flashing commercial crap. I’d rather be in the woods or doing other things besides being stuck in front of a screen. Sure, I like coding and map making, especially in the winter months but I don’t really need the Internet for that.

I do have a 23″ monitor I bought for $150 a few years back. Its great for mapping and coding. Map making is better on the big screen. The few times I’ve brought it along with me traveling for work websites do look nice on it. I guess I could buy an inexpensive HDTV adapter and get over the air television, but I really don’t want that in my home.

Just please, stop sending me those television ads.

January 30, 2016 Afternoon

Good afternoon. Currently mostly sunny and 39 degrees in Delmar. Tonight will be mostly cloudy, with a low around 33. South wind 6 to 10 mph. Bit of a chilly breeze this evening but fairly mild.

Sunset will be at 5:06 pm with twilight at 5:36 pm which is one minute and 19 seconds later then yesterday. Tonight we will have a Waining Gibbous Moon with 53% illuminated. It will rise at 11:40 pm.

Sunday will be mostly cloudy, with a high near 47. South wind around 7 mph. Warmer but not as nice today. There have been too many cloudy days recently.

Recovering from last night today. I also spent a fair bit of time working on maps of various state lands and finishing my PyQGIS scripting project. Going out to Five Rivers to watch the sun clear on this nice but cold evening.

Code Scrap for Exporting a QGIS Composer to a Vector PDF

This is the traditional method of Python Scripting to export a QGIS Composer as an Adobe Acrobat PDF file. This produces a vector PDF file regardless of your setting under “Print as a Raster”. This provides the highest quality print output, but may cause incorrect rendering if you use effects like multiply layers. Tomorrow I will post code I use for making PDFs, using compressed (but high resolution) Raster JPEG files embedded in the PDF files.

It’s possible you won’t need to import as many classes as I did. I just didn’t carefully go through the list to remove classes that are unnecessary (as they are neccessary for my plugin code). You will need to adjust the output file name and the window title for the Composer to whatever you named your Composer as. Remember if you use this in a plugin class, to make iface to self.iface or this code won’t work. Stupid stuff like that will trip you up.

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

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

c = composers[composerId].composition()

image = c.printPageAsRaster(True, QSize(),c.printResolution())

printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName("/tmp/"+QgsProject.instance().title()+".pdf")
printer.setPaperSize(QSizeF(c.paperWidth(), c.paperHeight()), QPrinter.Millimeter)
printer.setFullPage(True)
printer.setColorMode(QPrinter.Color)
printer.setResolution(c.printResolution())

pdfPainter = QPainter(printer)
c.renderPage(pdfPainter,0)
pdfPainter.end()

I hope this is helpful. I’m not a real PyQGIS pro, but if you have ideas or comments, please add them below.

Rensslear Plateau

I had trouble finding a clear example online of how to export a composer file as a Vector Adobe Acrobat PDF you have loaded in Quantum GIS via a Python plugin or script. This code that I put together does the trick.