Skip to content

Shapefile driver lies about geometry type #14602

@dbaston

Description

@dbaston

A common [case] I see that gives error code 1 but as a Warning is Shapefile -> GPKG when the .shp has MultiPolygon. I recently saw that warning also with ESRI File Geodatabase -> GPKG and MultiSurface. With CLI, it gives ( 3.14dev)

gdal convert poly_multipoly.shp out.gpkg
0...10...20..Warning 1: A geometry of type MULTIPOLYGON is inserted into layer
poly_multipoly of geometry type POLYGON, which is not normally allowed by the
GeoPackage specification, but the driver will however do it. To create a
conformant GeoPackage, if using ogr2ogr, the -nlt option can be used to
override the layer geometry type. This warning will no longer be emitted for
this combination of layer and feature geometry type.
.30...40...50...60...70...80...90...100 - done.

Many users will be familiar with that case and accustomed to specify -nlt. The message may be confusing in CLI since it refers to ogr2ogr, and gdal vector convert doesn't have an nlt option. Instead the solution is to use gdal vector set-geom-type. Maybe this is a code change in vector convert? The Migration Guide has "Converting a shapefile to a GeoPackage" giving ogr2ogr -> gdal vector convert but doesn't mention set-geom-type.

As a user I also wonder about the implications of creating a non-conformant GPKG. I would assume it's fine as long as the file will only be read by GDAL, but not if used in ArcGIS?

Originally posted by @ctoney in #14583 (comment)

Metadata

Metadata

Assignees

Labels

not for AI loversSee https://gdal.org/en/stable/community/ai_tool_policy.html

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions