[Gdal-dev] PostGIS and OGR - new try

Frank Warmerdam warmerdam at pobox.com
Sun Sep 16 14:08:04 EDT 2007


Brian Hamlin wrote:
> I am new to PostGIS, and am trying out the dataset that Refractions has 
> posted for the FOSS4G Integration showcase. In the main foss database 
> there is a table called border.
> 
> The spatial_ref_sys for that database calls out a projection "NAD83 / BC 
> Albers"...
> 
> If I run,    ogr2ogr -f KML t.kml PG:dbname=TheRightName border
> a KML file is produced, but the coordinates of the linestring are not 
> converted to Google Earth projection. The psatial_ref_sys is not 
> 'automagically' detected.
> 
> ogr2ogr -s_srs NAD83 xxxx
> still not usable results ?
> 
> ogr2ogr -s_srs NAD83 -t_srs WGS84 xxx
> still no good

Brian,

Try:

ogr2ogr -f KML -t_srs WGS84 t.kml PG:dbname=TheRightName border

This should use the source coordinate system from PostGIS and force
reprojection since you have selected a different output coordinate
system.

>   Since the output of KML will always be in the projection GE uses, 
> should -t_srs be necessary?  Perhaps I am completely missing something 
> basic?

It is my opinion that it is inappropriate for drivers themselves to
reproject geometries on the fly.  It is better that it be handled at
the application level (ie. ogr2ogr doing it based on -t_srs)

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




More information about the Gdal-dev mailing list