OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.79k stars 2.51k forks source link

OpenFileGDB driver possibly assigning geometry to points when they should be NULL/EMPTY #7986

Closed JustinP31 closed 1 year ago

JustinP31 commented 1 year ago

Expected behavior and actual behavior.

I expected to import this GDB SourceData_Copy.gdb.zip into Postgres using this ogr2ogr command
ogr2ogr -f PostgreSQL "PG:host='127.0.0.1' user='pguser' password='pguser' dbname='test_db' port='5432'" -lco SCHEMA=source1 -lco OVERWRITE=YES -preserve_fid --config PG_USE_COPY YES "/path/to/gdb/file/SourceData_Copy.gdb" -nlt GEOMETRY
where there are Points that contain NULL/EMPTY geometry, however what I'm seeing is the Points are getting assigned geometry. According to ESRI's check geometry tool these Points should be NULL.

Interestingly, It seems the FileGDB driver imports the NULL geometry for Points as expected but doesn't like Polygon geometry that contains NULL geometry (see error below). Whereas the OpenFileGDB driver will handle the NULL geometry for Polygons and Lines as expected but will assign Points geometry when they should be NULL/EMPTY.

The dataset includes layers of these geometry types: Points, Multi Polygon, and Multi Line String all containing NULL geometry.

Loading with OpenFileGDB driver: 2023-06-16_16-26-50

Loading with FileGDB driver: 2023-06-16_16-29-24

Error when loading Polygons with NULL geometry: ERROR 1: Failed attempting to import GDB WKB Geometry. OGRGeometryFactory err:6 ERROR 1: Failed to translate FileGDB Geometry to OGR Geometry for row 6 (Operation successful.) ERROR 1: Failed translating FGDB row [6] to OGR Feature (Operation successful.) ERROR 1: Failed attempting to import GDB WKB Geometry. OGRGeometryFactory err:6 ERROR 1: Failed to translate FileGDB Geometry to OGR Geometry for row 7 (Operation successful.) ERROR 1: Failed translating FGDB row [7] to OGR Feature (Operation successful.) ERROR 1: Failed attempting to import GDB WKB Geometry. OGRGeometryFactory err:6 ERROR 1: Failed to translate FileGDB Geometry to OGR Geometry for row 8 (Operation successful.) ERROR 1: Failed translating FGDB row [8] to OGR Feature (Operation successful.)



Even simply running these ogrinfo commands shows the same problem:

ogrinfo '/path/to/gdb/file/SourceData_Copy.gdb' Point1 --config OGR_SKIP FileGDB

OUTPUT:

Had to open data source read-only. INFO: Open of /path/to/gdb/file/SourceData_Copy.gdb'

using driver OpenFileGDB' successful.

Layer name: Point1 Geometry: Point Feature Count: 3 Extent: (6269037.630127, 1830269.087524) - (6373065.141907, 1943449.610474) Layer SRS WKT: PROJCS["NAD83 / California zone 6 (ftUS)", GEOGCS["NAD83", DATUM["North_American_Datum_1983", SPHEROID["GRS 1980",6378137,298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0,0,0,0,0,0,0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4269"]], PROJECTION["Lambert_Conformal_Conic_2SP"], PARAMETER["standard_parallel_1",33.88333333333333], PARAMETER["standard_parallel_2",32.78333333333333], PARAMETER["latitude_of_origin",32.16666666666666], PARAMETER["central_meridian",-116.25], PARAMETER["false_easting",6561666.667], PARAMETER["false_northing",1640416.667], UNIT["US survey foot",0.3048006096012192, AUTHORITY["EPSG","9003"]], AXIS["X",EAST], AXIS["Y",NORTH], AUTHORITY["EPSG","2230"]] FID Column = OBJECTID Geometry Column = SHAPE FULLNAME: String (125.0) Comment: String (75.0) OGRFeature(Point1):57925 FULLNAME (String) = EMPTY GEOM Comment (String) = (null) POINT (1.84422404740822e+15 1.84422404740822e+15)

OGRFeature(Point1):57926 FULLNAME (String) = EMPTY GEOM Comment (String) = (null) POINT (1.84422404740822e+15 1.84422404740822e+15)

OGRFeature(Point1):57927 FULLNAME (String) = EMPTY GEOM Comment (String) = (null) POINT (1.84422404740822e+15 1.84422404740822e+15)



ogrinfo '/path/to/gdb/file/SourceData_Copy.gdb' Point1 --config OGR_SKIP OpenFileGDB

OUTPUT:

INFO: Open of /path/to/gdb/file/SourceData_Copy.gdb'

using driver FileGDB' successful.

Layer name: Point1 Geometry: Point Feature Count: 3 Extent: (6269037.630127, 1830269.087524) - (6373065.141907, 1943449.610474) Layer SRS WKT: PROJCS["NAD83 / California zone 6 (ftUS)", GEOGCS["NAD83", DATUM["North_American_Datum_1983", SPHEROID["GRS 1980",6378137,298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0,0,0,0,0,0,0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4269"]], PROJECTION["Lambert_Conformal_Conic_2SP"], PARAMETER["standard_parallel_1",33.88333333333333], PARAMETER["standard_parallel_2",32.78333333333333], PARAMETER["latitude_of_origin",32.16666666666666], PARAMETER["central_meridian",-116.25], PARAMETER["false_easting",6561666.667], PARAMETER["false_northing",1640416.667], UNIT["US survey foot",0.3048006096012192, AUTHORITY["EPSG","9003"]], AXIS["X",EAST], AXIS["Y",NORTH], AUTHORITY["EPSG","2230"]] FID Column = OBJECTID Geometry Column = SHAPE FULLNAME: String (125.0) Comment: String (75.0) OGRFeature(Point1):57925 FULLNAME (String) = EMPTY GEOM Comment (String) = (null) POINT (nan nan)

OGRFeature(Point1):57926 FULLNAME (String) = EMPTY GEOM Comment (String) = (null) POINT (nan nan)

OGRFeature(Point1):57927 FULLNAME (String) = EMPTY GEOM Comment (String) = (null) POINT (nan nan)

Steps to reproduce the problem.

OGR2OGR (look in postgres afterwards)

Using FileGDB driver:

ogr2ogr -f PostgreSQL "PG:host='127.0.0.1' user='pguser' password='pguser' dbname='test_db' port='5432'" -lco SCHEMA=source1 -lco OVERWRITE=YES -preserve_fid --config PG_USE_COPY YES "/path/to/gdb/file/SourceData_Copy.gdb" -nlt GEOMETRY --config OGR_SKIP OpenFileGDB

Using OpenFileGDB driver:

ogr2ogr -f PostgreSQL "PG:host='127.0.0.1' user='pguser' password='pguser' dbname='test_db' port='5432'" -lco SCHEMA=source1 -lco OVERWRITE=YES -preserve_fid --config PG_USE_COPY YES "/path/to/gdb/file/SourceData_Copy.gdb" -nlt GEOMETRY

OGRINFO

Using OpenFileGDB:

ogrinfo '/path/to/gdb/file/SourceData_Copy.gdb' Point1 --config OGR_SKIP FileGDB

Using FileGDB:

ogrinfo '/path/to/gdb/file/SourceData_Copy.gdb' Point1 --config OGR_SKIP OpenFileGDB

Operating system

Ubuntu 18.04

Postgres 11

Postgis 3.3

GDAL version and provenance

Tested with GDAL 2.2.3 and GDAL 3.6.3

jratike80 commented 1 year ago

Is the gdb file created with some ESRI product? I can confirm that GDAL 3.8.0dev finds geometries POINT (1.84422404740822E+15 1.84422404740822E+15) from the point1 layer.

ArcGIS Pro opens all the layers so that the geometries are empty.

JustinP31 commented 1 year ago

Is the gdb file created with some ESRI product?

Yes, ArcMap 10.6.1

rouault commented 1 year ago

fix in https://github.com/OSGeo/gdal/pull/7989