Archive for November, 2012

Updated Indiana Breweries Map

A few months ago I followed Darren Cope’s Geography of Tim Horton’s blog post to create a similar map that showed breweries in Indiana.  A new brewery opened up down south so I decided to update the map.

To get the location I looked up the location on Google Maps then used the QGIS plugin OpenLayers to find the brewery on Google Maps’ Hybrid Map.  I added the point to my breweries PostGIS layer and re-imported the layer into GRASS along with a shapefile of the state.  From there I used v.to.rast.constant to convert those layers to rasters.

With the vectors converted to rasters I used r.mask to use the Indiana raster as a mask for the next step which is to use r.grow.distance to create the final map.  The result was exported with r.out.png and brought into GIMP to make the no data areas transparent.

To create the transparencies use Layer -> Transparency -> Add Alpha Channel then use the Select Region by Color tool to select the no data areas, then press the delete key to zap them away.  The image below is the result.

 

Location of breweries in Indiana

Indiana breweries

$_ today’s favorite bash shortcut of the day

In Bash and several other shells $_ stores the arguments of the most recent command.  This lets you do something like:

mkdir fun
cd $_

That’s a simple example, making a directory and switching into it.  Where it really comes in handy is when you’re like me and you give the wrong command with a million arguments and want to quickly fix your mistake.  $_ to the rescue!

You need ArcInfo for this? Seriously?

I had two line layers and needed to create points at where the layers intersected.  In QGIS this is done with the line intersection tool found in the Vector -> Analysis Tools menu.  Just give it the two input layers, name an output layer and you’re done.  As near as I can tell with ESRI tools you have to spring for ArcInfo so you can use the Feature to Lines tool as specified in this Ask the Cartographer post.

Watch your projections when using QGIS’s raster clipper

I needed to clip a county-wide Mr. Sid file down to just the area of interest for a project.  QGIS‘s raster clipper tool, a front end for gdal_translate, made that easy.  You can either clip by a selected extent, or by a masking polygon from a vector layer.  I did run into one problem, the project’s CRS was the local State Plane projection and the source raster was in UTM.  Gdal_translate returned the following error:

Computed -srcwin falls outside raster size of 28249x42326

Resetting QGIS’s project CRS to match the raster’s projection fixed the error.