Mateusz Loskot :: hacking on, working out, living up

GeoJSON Driver Errata

06 Nov 2007 | mloskot

In my today announcement of the OGR GeoJSON Driver, I stated as follows:

Unfortunately, OGR objects model does not allow to have geometries of different types in single layer.

Actually, this is not true or imprecise enough. The OGR model does support mixed geometry types in single layer. Such layer is defined as of type of wkbUnknown and it behaves similarly as, for instance, PostGIS layer (table) with geometry column defined as GEOMETRY type. The wkbUnknown means that a layer is ust fine and all geometry types are allowed in this layer.

In my previous post, I incorrectly said mixed types are not supported because I considered wkbUnknown as not valid type of layer, as something undefined or defined as unusable. Thanks to Frank and Chris who clarified me this subject.

Anyway, as a matter of fact I’ve correctly implemented support of mixed geometry types as defined in the OGR model. It means, that if you are accessing GeoJSON datasource serving features of mixed geometry types, the driver will preserve these types by default. Eventually, you can request to wrap geometries with OGRGeometryCollection type by setting GEOMETRY_AS_COLLECTION=YES variable.

Below, you can see how OGR GeoJSON handles collection of features with geometries of mixed types:

I hope it’s clarifies what I messed previously.

Fork me on GitHub