[gdal-dev] Writing Geometrycollection to ShapeFile datasource
Even Rouault
even.rouault at spatialys.com
Mon Oct 16 11:43:45 PDT 2017
On lundi 16 octobre 2017 09:08:57 CEST dmel wrote:
> Hi,
>
> I am implementing export service to export the geometries from our system to
> ShapeFile using OGR 1.11 library.
>
> The service create GeoJSON datasource from the JSON input, and then for each
> feature in the GeoJSON datasource it creates feature in ShapeFile
> datasourse.
>
> It all works well when all the features in the GeoJson are simple Geometry
> (POINT, LINESTRING, POLYGON) (Note: we don’t support mix geometries)
> But if the GeoJson data contains Point and GeometryCollection of Points,
> then Shapefile driver raise the error:
>
> “Attempt to write non-point( GeometryCollection ) geometry to POINT type
> shapefile.”
>
> Is this by design or bug because this works for Linestring and
> GeometryCollection of Linestring ( same for polygon).
> If this is by design, what the best way to handle this.
Danley,
This is a constraint of the Shapefile format that doens't support mixed
geometry types in the same layer.
In shapefile, you can put single LineString or GeometryCollection of
LineString (which are turned into MultiLineString) in the same layer.
But Point and MultiPoint (or GeometryCollection of Point) can't be mixed
together in the same shapefile
You could possibly instanciate a MultiPoint shapefile layer, and convert
Point's to MultiPoint's before writing them to the layer.
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list