[Gdal-dev] ogr2ogr MapINfo bug?

Bill Thoen bthoen at gisnet.com
Sat Nov 25 12:54:12 EST 2006


On Sat, Nov 25, 2006 at 11:24:42AM -0500, Frank Warmerdam wrote:
> 
> Ah, so the problem is, presumably, that OGR isn't seeing the geometry
> of the PostGIS tables properly.  You might want to verify this with ogrinfo
> against the postgis table.

It looks like using an sql statement with ogr2ogr is causing it to miss the
geometry. When I try ogrinfo on one record, I get these results:

$ ogrinfo -sql "select * from counties where fips='17055'" 
  "PG:dbname=spatial1"

INFO: Open of `PG:dbname=spatial1'
using driver `PostgreSQL' successful.

Layer name: sql_statement
Geometry: Unknown (any)
Feature Count: 1
Layer SRS WKT:
(unknown)
Geometry Column = the_geom
gid: Integer (0.0)
fips: String (0.0)
state: String (0.0)
county: String (0.0)
OGRFeature(sql_statement):0
  gid (Integer) = 576
  fips (String) = 17055
  state (String) = Illinois
  county (String) = Franklin

But when I try ogrinfo using the -where switch, I get a geometry, like so:

$ ogrinfo -where "fips='17055'" "PG:dbname=spatial1" counties

INFO: Open of `PG:dbname=spatial1'
using driver `PostgreSQL' successful.

Layer name: counties
Geometry: Multi Polygon
Feature Count: 1
Extent: (-124.817940, 24.521049) - (-66.949829, 49.384361)
Layer SRS WKT:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.01745329251994328,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]
Geometry Column = the_geom
county: String (66.0)
fips: String (5.0)
gid: Integer (0.0)
state: String (66.0)
OGRFeature(counties):0
  county (String) = Franklin
  fips (String) = 17055
  gid (Integer) = 576
  state (String) = Illinois
  MULTIPOLYGON (((-88.918323999999998 37.862324999999998,
-88.921287000000007 37.862295000000003,
-88.923396999999994 37.862273000000002,
-88.923800999999997 37.862273000000002,
-88.925372999999993 37.862260999999997,
-88.928235999999998 37.862239000000002, ... and so on.

So I'm not sure if this is a bug or I'm just not using the -sql switch
properly. Can you tell me what's going on and how to fix it?

- Bill Thoen




More information about the Gdal-dev mailing list