Opened 14 years ago
Closed 13 years ago
#3677 closed defect (wontfix)
OGR shape driver doesn't handle writing points to a multipoint shp.
Reported by: | cdestigter | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | 1.6.1 |
Severity: | normal | Keywords: | shape |
Cc: |
Description
If I write a polygon to a multipolygon shape, it works fine:
from osgeo import ogr, osr d = ogr.GetDriverByName("ESRI Shapefile") ds = d.CreateDataSource("/home/cdestigter/test_polygons") srs = osr.SpatialReference() srs.ImportFromEPSG(4326) layer = ds.CreateLayer("test_polygons", srs, ogr.wkbMultiPolygon) feature = ogr.Feature(layer.GetLayerDefn()) geom = ogr.CreateGeometryFromWkt('POLYGON((0 0,0 1,1 1,1 0,0 0))') feature.SetGeometryDirectly(geom) layer.CreateFeature(feature)
But if I do the same thing with a point instead of a polygon, it throws an error:
from osgeo import ogr, osr d = ogr.GetDriverByName("ESRI Shapefile") ds = d.CreateDataSource("/home/cdestigter/test_points") srs = osr.SpatialReference() srs.ImportFromEPSG(4326) layer = ds.CreateLayer("test_points", srs, ogr.wkbMultiPoint) feature = ogr.Feature(layer.GetLayerDefn()) geom = ogr.CreateGeometryFromWkt('POINT(0 1)') feature.SetGeometryDirectly(geom) layer.CreateFeature(feature)
I'm using gdal 1.6.1 but from a brief scan of the code, it looks like this behavior is in trunk too.
Is there some reasoning behind this behaviour? Seems like a bug to me.
I'm hoping to fix this and have a patch up shortly.
Attachments (1)
Change History (5)
comment:1 by , 14 years ago
by , 14 years ago
Attachment: | gdal-multipoint-fix.diff added |
---|
comment:3 by , 14 years ago
Component: | default → OGR_SF |
---|---|
Keywords: | shape added |
It is possible to write polygon or multipolygons to a polygon shapefile because the types are not distinguished in the shapefile format.
However, point and multipoint are distinct types of shapefile, and they are distinct types of simple features geometry. There is no expectation in OGR that they should be interchangeable.
The proposed patch might be relatively harmless (hard to say without substantial review), but at best it is adding some extra convenience behavior to just one driver. I am not keen to apply it.
comment:4 by , 13 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Closing old ticket since Frank's comment above makes a lot of sense.
The error I get is: