[FWTools] Get lat & long from shapefiles in SPC

Frank Warmerdam fwarmerdam at gmail.com
Thu Jun 9 16:46:36 EDT 2005

On 6/3/05, Ron Phillips <RPhillips at engineer.co.summit.oh.us> wrote:
> My agency works mostly in State Plane Coordinates, and we have many
> shapefiles that contain SPC-based X and Y. 
> I'd like to just enter the point-type shapefile path and the database path
> and get a datatable with Easting, Northing, Lat, and Long all in there with
> the data from the dbf. (For polygon and polyline data, I just extract the
> bounding box, not all the rings or segments.) 
> Right now I am getting the SPC data out of the shapefiles and putting it
> into a datatable, then using CorpsCon to find the Lats and Longs, but I'd
> like to get rid of that step. 
> I am fairly familiar with Python, but not with GIS data, per se. Is there
> anything in FWTools or Shapefile lib that can help me? 


Sorry for the delayed response.  I was off on vacation.  

You can indeed accomplish what you want with Python 
and the bindings for the OGR package.   I don't have time just
now to prepare a complete example, but you can look through a
couple existing scripts to get an idea of how this can be approached.

The tolatlong.py script transforms a pixel/line location on an image
to latlong, incuding a reproject step.  If you look at the portion from
the comment "Build Spatial Reference object" on you can see how
to do the reprojection. 


Next, you can skim the "get_sound.py" script for an example
of how to read OGR supported vector files in Python:


This script actually reads an S-57 file, splits multi-point geometries
into single points and adds the elevation as an attribute before 
writing to an output shapefile.  But hopefully it provides some clues
as to how to read files in OGR. 

Keep in mind that the OGR Python bindings follow the C++ 
classes fairly closely for most things, so referring to the 
ogr.py and OGR class documentation an be helpful.


Best regards,

I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the FWTools mailing list