GDAL Datasource

The OGR library within GDAL provides access to feature data from a variety of vector sources including shapefiles and PostGIS.

class shelley.datasources.gdal.FeatureSource(name, driver=None, layer_name=None, sql=None, extent=None)
Parameters:
  • name (string) – identifies of the datasource, relative to driver if supplied
  • driver (string) – optionally specifices the OGR driver to use
  • layer_name – if needed identifies the layer within the datasource
  • sql (string) – used with a database driver to retrieve the data
  • sql_filter – callable for altering the sql with the supplied bounds if OGR hasn’t implemented the spatial filter

Shape files

>>> from shelley.datasources.gdal import FeatureSource
>>> data_source = FeatureSource('world_boundaries/places.shp')
>>> features = data_source.features()

PostGIS

>>> data_source = FeatureSource('PG:host=localhost dbname=gis', driver='PostgreSQL', sql='select * from planet_osm_roads')

Table Of Contents

Previous topic

Data sources

Next topic

GeoDjango Datasource

This Page