I am trying to import a shapefile (multipolygon) in an app with ogr but I got an error about invalid geom type. If I inspect the data with ogr like this:

datasource = ogr.Open("c:\\temp\\data.shp")
layer = datasource.GetLayer(0)

The print returns:


I wonder what Geom Type is this. Is it an error in the data or is it a real Geom Type?

Edit: After using ogrinfo as elrobis suggested I have this output:

INFO: Open of C:\\ArcGIS data\\Mun_region.shp' using driverESRI Shapefile' successful.

Layer name: Mun_region Geometry: 3D Polygon Feature Count: 2 Layer SRS WKT: (unknown) OGR_GEOMETRY: String (0.0) OGRFeature(Mun_region):0

OGRFeature(Mun_region):1 OGR_GEOMETRY (String) = POLYGON

  • 1
    What kind of app are you trying to import to? I can think of two options for you: 1) If you can import using ogr2ogr, you can set the -nlt flag to -nlt geometry, and ogr2ogr will attempt to insert both geom types. Alternatively, 2) you can just explode the multipart polygons to single part---realizing you'll probably need to involve some joining on a common field later---then run your import.
    – elrobis
    Apr 16, 2013 at 20:05
  • 2
    ogr.wkbPolygon25D == -2147483645
    – Mike T
    Apr 16, 2013 at 21:23
  • Mike, ogr.wkbPolygon25D is 0x80000003, so it looks like there might be a failure to read as unsigned int in OGR's Python bindings. I was seeing the same thing in Fiona before this change: github.com/sgillies/Fiona/commit/….
    – sgillies
    Apr 17, 2013 at 18:22

1 Answer 1


Ha. You may have an interesting problem here. Seeing that you have access to GDAL, and assuming you have access then to ogrinfo.. please adjust this expression and run it against your dataset to check for the distinct geometry types it contains:

Use OGRINFO to Return the Distinct Geometries in a Dataset

ogrinfo "D:\LongPathTo\Data\MyPolygons.shp" -geom=no -sql " SELECT DISTINCT OGR_GEOMETRY from MyPolygons "

Basically what I'm doing here is asking ogrinfo, by way of OGR SQL to show me a list of the distinct geometry types it encounters in my dataset. For my example, the output is like this:

C:\Documents and Settings\soloorbit>ogrinfo "D:\LongPathTo\Data\MyPolygons.shp" -geom=no -sql " SELECT DISTINCT
OGR_GEOMETRY from MyPolygons "
INFO: Open of `D:\LongPathTo\Data\MyPolygons.shp'
      using driver `ESRI Shapefile' successful.

Layer name: MyPolygons
Geometry: Polygon
Feature Count: 2
Layer SRS WKT:
OGR_GEOMETRY: String (0.0)


So in this case---note that I have both POLYGON and MULTIPOLYGON types in this dataset. That's because ESRI allows that by default. But often, the open source stuff is more restrictive, and you generally have to say "hey this is okay!", or alternatively explode your multipart polys into single part.

....but more than anything, right now I'm just curious how many distinct geometries you have in that table. I wonder if it could be a null geometry?

CAVEAT: I've noticed the double-quote symbol (") has a tendency to get strange once it's posted into a web thread, so I highly-recommend just typing out the full expression into either notepad or your command window first, rather than merely copy/pasting it, then tweaking it.

Best / Elijah

  • 1
    You might also want to look at an older GDAL_DEV thread that may explain what you've encountered. Here's the question, and here's the answer
    – elrobis
    Apr 16, 2013 at 19:34
  • thank you, I didnt know about ogrinfo. Interesting tool. You were right I got two geometry type in the same shapefile. I have edited my post with the output Apr 16, 2013 at 20:01
  • Do you know how I could handle those cases? Does this geomtype is really wkbPolygon25D? Apr 16, 2013 at 20:02
  • 1
    I confirm: ogr geom type is ogr.wkbPolygon25D for this shapefile. Apr 16, 2013 at 20:27
  • 2
    You can certainly try handling it as wkbPolygon25D, but I'm concerned that could be a red herring. @Burton449, First, if you have GDAL 1.8 or better, try using ogr2ogr just to create a new shapefile with all single part geometries, then see if you can import it using your normal approach. It's about like this: ogr2ogr "C:\ArcGIS data\Mun_region_SINGLEPART.shp" "C:\ArcGIS data\Mun_region.shp" -explodecollections
    – elrobis
    Apr 16, 2013 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.