gws.gis.gdalx

GDAL/OGR wrapper.

Source code: gws.gis.gdalx

Package Contents

class gws.gis.gdalx.DriverInfo(*args, **kwargs)

Bases: gws.Data

Basic data object.

This object can be instantiated by passing one or or dict arguments and/or keyword args. All dicts keys and keywords become attributes of the object.

Accessing an undefined attribute returns None and no error is raised, unless the attribute name starts with an underscore.

index: int
longName: str
metaData: dict
name: str
gws.gis.gdalx.drivers() list[DriverInfo]

Enumerate GDAL drivers.

exception gws.gis.gdalx.Error

Bases: gws.Error

GWS error.

gws.gis.gdalx.open_from_image(image: gws.Image, bounds: gws.Bounds) RasterDataSet

Create an in-memory Dataset from an Image.

Parameters:
  • image – Image object

  • bounds – geographic bounds

gws.gis.gdalx.open_raster(path: str, mode: str = 'r', driver: str = '', default_crs: gws.Crs | None = None, **opts) RasterDataSet

Create a raster DataSet from a path.

Parameters:
  • path – File path.

  • mode – ‘r’ (=read), ‘a’ (=update), ‘w’ (=create/write)

  • driver – Driver name, if omitted, will be suggested from the path extension.

  • default_crs – Default CRS for geometries (fallback to Webmercator).

  • opts – Options for gdal.OpenEx/CreateDataSource.

gws.gis.gdalx.open_vector(path: str, mode: str = 'r', driver: str = '', encoding: str = 'utf8', default_crs: gws.Crs | None = None, **opts) VectorDataSet

Create a vector DataSet from a path.

Parameters:
  • path – File path.

  • mode – ‘r’ (=read), ‘a’ (=update), ‘w’ (=create/write)

  • driver – Driver name, if omitted, will be suggested from the path extension.

  • encoding – If not None, strings will be automatically decoded.

  • default_crs – Default CRS for geometries (fallback to Webmercator).

  • opts – Options for gdal.OpenEx/CreateDataSource.

Returns:

DataSet object.

class gws.gis.gdalx.RasterDataSet(path, gd_dataset, encoding='utf8', default_crs: gws.Crs | None = None)

Bases: _DataSet

create_copy(path: str, driver: str = '', strict=False, **opts)

Create a copy of a DataSet.

class gws.gis.gdalx.VectorDataSet(path, gd_dataset, encoding='utf8', default_crs: gws.Crs | None = None)

Bases: _DataSet

create_layer(name: str, columns: dict[str, gws.AttributeType], geometry_type: gws.GeometryType = None, crs: gws.Crs = None, overwrite=False, *options) VectorLayer
layer(name_or_index: str | int) VectorLayer | None
layers() list[VectorLayer]
transaction()
class gws.gis.gdalx.VectorLayer(ds: VectorDataSet, gd_layer: osgeo.ogr.Layer)
defaultCrs: gws.Crs
encoding: str
gdDefn: osgeo.ogr.FeatureDefn
gdLayer: osgeo.ogr.Layer
name: str
count(force=False)
describe() gws.DataSetDescription
get(fid: int) gws.FeatureRecord | None
get_all() list[gws.FeatureRecord]
insert(records: list[gws.FeatureRecord]) list[int]