[gdal-dev] ogr2ogr problem

pcreso at pcreso.com pcreso at pcreso.com
Tue Jan 6 17:27:21 EST 2009


Hi Frank,

My current workaround is to use the GML driver instead of Mapinfo (don't extract the geometries as geometries), then grep/sed/tr the GML file to get a GMT one. This does not actually use ogr2ogr to get the geometries, but returns them as a field with the X & Y coords in a space separated string.

As this works for now, and later versions of ogr work perfectly, pending an upgrade to the whole server (hardware/OS/apps, etc) I don't want to waste too much on this issue.


This would be similar to using your suggested ogrinfo option, which could be parsed much as the GML:

ogrinfo 'PG:host=wms dbname=db_trawl user=woodb' -sql "select station_no as fielda, x(startpoint(trackline))||' '||y(startpoint(trackline)) as fieldb, x(endpoint(trackline))||' '||y(endpoint(trackline)) as fieldc from station" 

gives:
INFO: Open of `PG:host=wms dbname=db_trawl user=woodb'
using driver `PostgreSQL' successful.

Layer name: sql_statement
Geometry: Unknown (any)
Feature Count: 315
Layer SRS WKT:
(unknown)
fielda: Integer (0.0)
fieldb: String (0.0)
fieldc: String (0.0)
OGRFeature(sql_statement):0
  fielda (Integer) = 16
  fieldb (String) = 174.37767 -73.0465
  fieldc (String) = 174.358 -73.0535

OGRFeature(sql_statement):1
  fielda (Integer) = 32
  fieldb (String) = 170.1775 -74.5895
  fieldc (String) = 168.96917 -74.64633

...


I think my geometries are all 2D, not 2.5D; from /d of the underlying table (unless I'm misunderstanding something):

Check constraints:
    "enforce_dims_endp" CHECK (ndims(endp) = 2)
    "enforce_dims_fulltrack" CHECK (ndims(fulltrack) = 2)
    "enforce_dims_startp" CHECK (ndims(startp) = 2)
    "enforce_dims_trackline" CHECK (ndims(trackline) = 2)



If I use your ogrinfo suggestion with a geometry column, it gets very lost & core dumps, suggesting the problem is with ogr reading the Postgis geometries somewhere, as below:

> ogrinfo 'PG:host=wms dbname=db_trawl user=woodb' -sql "select station_no, trackline from station"
INFO: Open of `PG:host=wms dbname=db_trawl user=woodb'
using driver `PostgreSQL' successful.

Layer name: sql_statement
Geometry: Unknown (any)
Feature Count: 315
Extent: (-5717190450301640785970682800244215736945715316512428951197211575738106802013888901421664366269233555558457342954974172221687531082569199376261222136447409698108740094360547229053971119731381878561004632469852618902278828573782927974207336510241341037769478970725094098994178086652986735885695745332871168.000000, -9871135095353366917847063186847407682388671842598713063065415824075662651770097930171516163014958694292472190782907640136317191274480220040216468228691291341349835566608217461232482779370461343605893205826545378596837338667087445935757592416299456975387985504062928627793559412582260514381297518650664681472.000000) - (1277337798102220679460078536343576682283168806678692826561630235159815610796137002102373097915286848697179165980283196956142360312571899942873069950902292109004803630688694832971224141724392311796898148316508111355731718691277357048888867371806748260804557380400483866651109436947420166353846272.000000,
 5486124089231092234727215697548580807398821068064494117442730014066340285828415568284781387371069552055991069241456364266374806234938889971978269653828033691802760405705186914144995030772391558383082593756024124155774550718318308840030730608253965942872972835827726072782531552189201291990798214723796992.000000)
Layer SRS WKT:
(unknown)
station_no: Integer (0.0)
OGRFeature(sql_statement):0
  station_no (Integer) = 16
Bus error (core dumped)
>                        


Thanks,

   Brent



--- On Wed, 1/7/09, Frank Warmerdam <warmerdam at pobox.com> wrote:

> From: Frank Warmerdam <warmerdam at pobox.com>
> Subject: Re: [gdal-dev] ogr2ogr problem
> To: pcreso at pcreso.com
> Cc: gdal-dev at lists.osgeo.org
> Date: Wednesday, January 7, 2009, 10:50 AM
> pcreso at pcreso.com wrote:
> > An example ogr2ogr command is:
> > 
> > ogr2ogr -f "Mapinfo File" -dsco
> "FORMAT=MIF" -nln sql ttt 'PG:host=wms
> dbname=db_trawl user=woodb' -sql "select
> station_no, trackline from station"   
> 
> Brent,
> 
> I'm not sure what is going on, but I'd suggest you
> try :
> 
>   ogrinfo 'PG:...' -sql "select station_no,
> trackline from station"
> 
> to see how OGR sees the result from the SQL statement.  If
> it is all
> goofed up, then try just using the table directly, instead
> of issuing
> custom SQL and see if that helps at all.
> 
> If the PG results are coming back fine, then it must be an
> issue with the
> mapinfo writer but this is pretty hard to imagine.  I do
> wonder if your
> 2.5D geometries might be throwing something for a loop.
> 
> 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 gdal-dev mailing list