Friday, December 19, 2014

Monday, December 15, 2014


Here's a nice Garmin GPX to shapefile converter using PyShp by Matt Rantala from his blog


Wednesday, December 3, 2014

WKT EPSG Strings Made Easy

This quick post is a follow on to my posts on map projections and creating .prj files for shapefiles.
 The .prj file format, created by Esri originally but now recognized by most geospatial software, is just a text file with a WKT string for the projection information.  Most of projections can be referenced by a simple EPSG code which is just a number.  Usually you'll have this number handy and need to look up the full WKT string on

Dr. David Forrest, a research scientist at the Virginia Institute of Marine Sciences, sent me a simple function to make fetching WKT projection strings easy:

def getPRJwkt(epsg):
   Grab an WKT version of an EPSG code
   usage getPRJwkt(4326)

   This makes use of links like
   import urllib
   sr = ""
   f=urllib.urlopen(sr + "/ref/epsg/{0}/prettywkt/".format(epsg))
   return (

So then getting a WKT projection string is as easy as:

>>> wkt = getPRJwkt(4326)
>>> print wkt
        SPHEROID["WGS 84",6378137,298.257223563,

There's another, newer website called that has some additional features beyond  The differences are in the FAQ on this page.

Monday, December 1, 2014


In Chapter 8 of my book, the shapefile doesn't have a .prj file which isn't a big deal for the example

but can be annoying if you try to open it in QGIS or ArcGIS.  There was also an unused numpy array in the example so I updated the whole package.  You can download the updated script and data here:

This example is the very first example in the chapter.  The second example shows you how to classify the output data to create the image shown here.

"Learning Geospatial Analysis with Python" Cyber Monday Sale

The print edition of Learning Geospatial Analysis with Python qualifies for a 30% discount on until midnight tonight using discount code HOLIDAY30 at checkout.  This is for the print edition only which is black and white as are most programming books as opposed to the eBook which is full color.  Very soon I will make an image catalog available for download for people with the print edition.  This detail isn't critical as most of the illustrations are not color dependent with the exception of a 1 or 2 remote sensing examples where color is helpful.  The image catalog will give you the best of both worlds and with a 30% savings to boot!