using ogr2ogr to create pt shp file from dbf w/ lat-lon fields

Frank Warmerdam warmerdam at POBOX.COM
Wed Mar 22 10:46:43 EST 2006


Emilio Mayorga wrote:
> I have a polygon shape file that has lat & lon fields for the centroid
> (the polygons are simple rectangles). I'd like to write a simple batch
> process to read those lat-lon fields and create a point shape file
> that also includes all the other attributes. I'd like to keep this as
> simple as possible, so I figured I could use ogr2ogr.
> 
> It sounds like I need to set up a Virtual Spatial Data file. The
> "Virtual Spatial Data (ODBC/OVF)" MapServer document says that I could
> use an ODBC connection after setting up a DSN. I have unixODBC
> installed on a RedHat server, but I don't see a dbf/dbase driver, and
> I can't find one either in the unixODBC home page.
> 
> Alternatively, I could try to export the dbf to a text file (say,
> csv), using something like the dbflist utility (part of the dbf2info
> utilities; I've never used them, but I assume I can set them up!). The
> MapServer document seems to imply that I could then set up an OVF to
> link directly to flat text files without an ODBC DSN, but I can't find
> any examples; I only see ODBC examples.
> 
> Any advice on what's the easiest approach to accomplish this? Thanks!

Emilio,

The OVF mechanism can be used without ODBC.  In this case I would suggest
you copy the .dbf file to a new name so it can be used in isolation
via OVF as a spatial-data-less input file.  Then you would use normal
OVF mechanisms, but instead of setting the SrcDatasource to an ODBC
connection string, just give the path to the .dbf file.

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    | President OSGF, http://osgeo.org



More information about the mapserver-users mailing list