Hot answers tagged

2

It's possible to get the layer geometry type without reading a feature. ds = ogr.Open(your_input_file) layer = ds.GetLayer() layer_defn = layer.GetLayerDefn() ogr.GeometryTypeToName(layer_defn.GetGeomType()) 'Polygon'


1

OGR geometry type codes of 25D geometries are small negative numbers https://gist.github.com/walkermatt/7121427 -2147483647 Point25D -2147483646 LineString25D -2147483645 Polygon25D -2147483644 MultiPoint25D -2147483643 MultiLineString25D -2147483642 MultiPolygon25D 0 Geometry 1 Point 2 Line 3 Polygon 4 ...


1

Behavior was changed in version 3.0 (and was the reason to bump version into 3). Documentation is in https://trac.osgeo.org/gdal/wiki/rfc73_proj6_wkt2_srsbarn. For getting the old behavior with GDAL 3 use SetAxisMappingStrategy?(OAMS_TRADITIONAL_GIS_ORDER)


1

You can do that with ogr2ogr, both on Python and on the command line. You first need to create a virtual OGR datset with your two shapefiles, points.shp and grid.shp, which you'll describe as a file, let's call it data.vrt: <OGRVRTDataSource> <OGRVRTLayer name="grid"> <SrcDataSource>grid.shp</SrcDataSource> <...


1

because data source parsing depends of provider you have to: QgsProviderRegistry.instance().decodeUri( layer.providerType(), layer.dataProvider().dataSourceUri() ) so in case of a file based provider you have decoded = QgsProviderRegistry.instance().decodeUri( layer.providerType(), layer.dataProvider().dataSourceUri() ) decoded['path']


Only top voted, non community-wiki answers of a minimum length are eligible