Sunday Tip Day: Convert a shapefile to text with linux

Never apologise for delayed posts… this is a Sunday Tip Day post, not a Thursday! Anyhow…

I just found a super little cross-platform utility that takes shapefiles and dumps them to a variety of text-based formats. Download it here, and simply unzip it to use it.

There isn’t much documentation, but basically your options are to download to gpx or spreadsheet. The following gives you a simple delimited text file with the coordinates and values from your attribute table:

./shp2text -–spreadsheet /path/to/your/shapefile.shp > /path/to/output.txt

Bob is indeed your mother’s brother.

4 Comments so far

  1. Tom Kralidis on May 12th, 2008

    Cool! Note that OGR (http://www.gdal.org/ogr/), more specifically ogr2ogr, will convert from/to a variety of GIS formats; work checking out.

  2. Tom Kralidis on May 12th, 2008

    s/work/worth/ :)

  3. Mateusz Łoskot on May 12th, 2008

    There is also shpdump utility from Shapelib (http://shapelib.maptools.org/). Certainly, it does not use any format usable with popular GIS packages, but it’s useful for some simple & fast data investigation.

  4. admin on May 12th, 2008

    Tom, Mateusz, thanks for stopping by. What I particularly like about this little tool (and I’m not sure if the other options will do this- let me know if they do) is that it gives you the coordinates, even if you didn’t specifically record them as attributes. Very handy! I’ll look at shpdump though.

Leave a reply