Mapping in python? Transforming shapefile so that basemap can read them?

Andrew MacIntyre andymac at bullseye.apana.org.au
Sat Sep 12 05:39:20 EDT 2009


C Barr Leigh wrote:
> I'm trying to get started with plotting maps in python. I need to read
> "shape files" (.shp) and make maps. There seem to be many efforts but
> none is complete? I'm looking for suggestions and troubleshooting.
> 
> The basemap package is obviously at an impressive stage and comes with
> some data:
> http://www.scipy.org/Cookbook/Matplotlib/Maps
> 
> but it cannot read shapefiles when their coordinates are not in
> geographic projection. min are in a lambert, so the readshapefile
> fails.
> 
> Apparently there is a utility that can convert a .shp file to lat/lon
> coordinates, but it fails for me. “You can convert the shapefile to
> geographic - coordinates using the shpproj utility from the shapelib
> tools - (http://shapelib.maptools.org/shapelib-tools.html)"
>  For me, this gives:
> “unable to process projection, exiting...”

Someone else has already mentioned GDAL which is actually the raster
part of the GDAL/OGR duo; OGR is the vector toolset which understands
shapefiles.  There are a couple of other packages possibly worth exploring:
- Thuban   (http://thuban.intevation.org)
- GRASS    (http://grass.itc.it/)
- Shapelib (http://shapelib.maptools.org/)
- FWTools  (http://fwtools.maptools.org/)

Shapefiles, except for the coordinate system support included in ESRI's
more recent products, are documented in a publicly accessible PDF which
googling for "ESRI shapefile" should find.

-- 
-------------------------------------------------------------------------
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia




More information about the Python-list mailing list