3

I'm new to ogr. I tried to copy a WFS layer to shapefile using CopyLayer but I get this error.

ERROR 6: Geometry type of `Multi Curve' not supported in shapefiles. Type can be overridden with a layer creation option of SHPT=POINT/ARC/POLYGON/MULTIPOINT/POINTZ/ARCZ/POLYGONZ/MULTIPOINTZ/MULTIPATCH.

How can I override the geometry type? Where do I apply the SHPT option?

from osgeo import ogr

url = 'https://data.gov.au/geoserver/brimbank-stormwater-pipes/wfs'
wfs_drv = ogr.GetDriverByName('WFS')
wfs_ds = wfs_drv.Open('WFS:' + url)
layer = wfs_ds.GetLayer()

driver = ogr.GetDriverByName('ESRI Shapefile')
dataSource = driver.Open(shp, 0)
shp_layer = dataSource.GetLayer()
feature = shp_layer.GetNextFeature()
geometry = feature.geometry()
layer.SetSpatialFilter(geometry)
out_file = r'C:\stormwater-pipes.shp'
out_ds = driver.CreateDataSource(out_file)
out_ds.CopyLayer(layer, out_file)
2
  • Maybe the curve geometry test in github.com/OSGeo/gdal/blob/master/autotest/ogr/ogr_shape.py could help.
    – user30184
    Commented Nov 16, 2020 at 17:46
  • I tried to copy a WFS layer to shapefile, you don't need to copy the WFS data to shapefile, as this WFS server provides SHAPE-ZIP as one of its outputs: https://data.gov.au/geoserver/brimbank-stormwater-pits/wfs?service=WFS&request=GetFeature&version=1.0.0&typename=brimbank-stormwater-pits:ckan_3f07bec5_99c2_491f_8d39_b6061891ebb1&outputFormat=SHAPE-ZIP&
    – nmtoken
    Commented Nov 17, 2020 at 13:35

1 Answer 1

2

Try the following:

from osgeo import ogr

url = 'https://data.gov.au/geoserver/ows?service=wfs'
wfs_drv = ogr.GetDriverByName('WFS')
wfs_ds = wfs_drv.Open('WFS:' + url)
layer = wfs_ds.GetLayer('brimbank-stormwater-pipes:ckan_a920c6fd_2c34_4b66_adcc_101f49d5e8a8')

driver = ogr.GetDriverByName('ESRI Shapefile')

out_file = r"D:\\stormwater-pipes.shp"
out_ds = driver.CreateDataSource(out_file)

out_ds.CopyLayer(layer, out_file, ['SHPT=ARC'])

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.