[postgis-users] help: ogr2ogr Mapinfo Export

Frank Warmerdam warmerdam at pobox.com
Thu Mar 11 06:29:28 PST 2004


Jeremy Palmer wrote:
> Hi,
> 
>  
> 
> I have been exporting some GPS point data (Lat and Long WGS 84) from 
> postgresql to mapinfo TAB format with the ogr2ogr tool. I have had no 
> problem exporting data straight from postgres tables, however when I use 
> SQL select statements for export to the mapinfo tab file it seems that 
> the coordinates are being treated in meters and not decimal degrees. 
> Does anyone know the reason for this? Here is the ogr2og command I was 
> using.
> 
>  
> 
> ogr2ogr -f "MapInfo File" street_address PG:dbname=geodb –sql “select 
> id, shape from crs_address where id > 1201” -nln street_address

Jeremy,

The problem is that ogr2ogr needs a coordinate system for a layer when
writing to tab files in order to establish various info in the .tab file.
The OGR PostGIS drive reads the coordinate system from the GEOMETRY_COLUMNS
table for regular spatial tables.  But it doesn't know how to figure out the
coordinate system for an arbitrary SELECT statement.

Assuming your data is in WGS84, you should be able to override the output
coordinate system with the -a_srs flag to ogr2ogr.   Something like:

ogr2ogr -f "MapInfo File" street_address PG:dbname=geodb \
    –sql “select id, shape from crs_address where id > 1201” \
    -nln street_address -a_srs WGS84

Good luck,
-- 
---------------------------------------+--------------------------------------
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 postgis-users mailing list