Archive for April, 2012

How far away are you from beer on a Sunday in Indiana?

Answer:  At most 50 miles.

Inspired by GIS blogger Darren Cope’s analysis of Tim Horton’s locations in Canada I decided to figure out how far you are at any given time from a microbrewery in Indiana.   Instead of Canadian coffee and donuts I mapped brewery locations.  I pulled the Brewer’s Guild of Indiana’s membership list (and took out Bee Creek, I’m pretty sure they’re closed).  This is a vital map because Indiana’s blue laws prohibit alcohol sales on Sundays except at microbreweries and vineyards.   Two things I don’t like on Sundays, wine and crossing state boundaries so this was a vital project for me.  I found that I really don’t want to be in northeast Dubois County on a Sunday. Seriously, 50 miles.  Dang.  At least people in Vincennes and Terre Haute can jump over to Illinois for a 6 pack.

Distances to Indiana breweries

I followed Cope’s steps except to get the lat / long for the breweries I had to geocode them against the TIGER street centerlines and instead of using GRASS directly I used QGIS’s GRASS plugin.  This article was a big help on getting a GRASS workspace set up to create the raster.

Advertisements

Reprojecting data with Postgis 2.0

There are so many awesome new features in PostGIS 2.0 but one of my favorites is the UpdateGeometrySRID function.  If you needed to reproject data in old versions you had to use a combination of Transform and SetSRID functions.  Now all you need to do is:

SELECT UpdateGeometrySRID('schema', 'table','geometry_column', SRID);

Easy peasy!

If this was available before 2.0 please travel back and time and tell me.  It will save me a few headaches.

Using the TIGER Geocoder from QGIS

Edit:

Not long after I posted this I found an easier method, not sure why I didn’t update this post.  Anyway rather than mess around with UUIDs, just use Postgres’ window function.  In this case the row_number function will generate the unique integers that QGIS needs to display your dynamic layer.  Replace the uuid_generate_v4() with:

SELECT row_number() OVER () As id,

Easy peasy.

 

I’ve been trying to use the Fast SQL Layers plugin with QGIS to map results from TIGER Geocoder queries.  The query below works, it will place point(s) but trying to open the attribute table crashes QGIS.  The identify tool works, but you will get an error stating the cursor has been lost.  I think it has something to do with the UUIDs, but I’m not positive.    Anyway, the query is after the jump.

Continue reading

PostGIS 2.0 PKGBUILD for Arch Linux

PostGIS 2.0 is now in the official repository.  Ignore all this nonsense.

PKGBUILD linked below now builds PostGIS 2.0.1.  See this post for details.

I’ve put together a PKGBUILD file you can use if you want to install PostGIS 2.0 on your Arch system.  I’m not going to put it on AUR because it would conflict with the existing package, and also because I’ve never done this before so use this at your own risk.  You can download the PKGBUILD from here:  https://github.com/philbns/PostGIS-2.0-PKGBUILD.

I didn’t tarball the PKGBUILD so you can just download it to an empty directory and run

makepkg -s

to build the package and then

pacman -U postgis-2.0.0-1-x86_64.pkg.tar.xz

to install it.

Once the package is installed look at the PostGIS manual to see how to set up or upgrade a spatial database.

This build includes the GUI shapefile loader. If you don’t want it or don’t need it edit –with-gui out of the ./configure statement and remove gtk2 from the dependencies.

Using QGIS to Georeference images

It is pretty easy and straightforward to use QGIS to georeference raster images.  There is a georeference plugin that is installed by default.

To use it:

  • Go to the Plugins menu, Manage Plugins, and turn on the Georeferencer GDAL plugin.
  • Load your layer containing the control points the raster is to be tied to
  • In the Plugins menu go to the Georeferencer entry and select Georeferencer
  • In the Georeferencer window load the raster to be georeferenced
  • Click the “Add Point” button, then select your first control point on the raster
  • In the window that pops up click the “From Map Canvas” button
  • In QGIS use the “Toggle Editing” button, it looks like a pencil, to select the corresponding control point
  • Go back to the Georeferencer window to select the next control point.  You’ll need at least 3 points
  • Once you have all your points click the “Start Georeferencing” button in the Georeferencer window
  • From the new window that pops up you can set your coordinate system, decide if you want a seperate world file, and if you want a pdf showing a report of the actions performed among other things

 

Gnome 3 Extensions

Recently I switched my laptop from OpenBox to Gnome.  Why?  Who knows, but I’m enjoying Gnome much more  on my laptop than I did on desktop.

One new feature of Gnome 3 is it’s ability to extend and enhance the Gnome Shell with extensions.   You can find a collection of extensions here.  You can use the site to install new extensions, or from this page you can see which extensions you have installed and you can uninstall unneeded extensions or turn extensions on or off.

After the jump I’ll go over a few extensions I’ve found helpful.

Continue reading

PostGIS 2.0 released!

PostGIS 2.0 is finally out!  Full details here.