TransWikia.com

How to override shapefile geometry type in OGR

Geographic Information Systems Asked by jonk on August 1, 2021

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)

One Answer

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'])

Correct answer by cm1 on August 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP