This is a python package which extends and enhances the flexibility and functionality of Ordnance Survey NGD API - Features.
- Wrapping core OS NGD API - Features functionality
- Calls to the Features and Collections endpoints can be made through python functions.
- Limit Extension
- The default upper limit for the number of features returned can be extended above the default of 100 through automatic pagination.
- Geometry Extension
- Multi-geometry search areas can be provided as spatial filters, including Geometry Collections.
- Each search area is searched in turn.
- The base NGD API is low-performing when multigeometries are searched and the component geometries are a long way apart. The wrapper resolves this issue.
- Collection Extension
- Multiple collections can be searched at once.
- This is useful when data relevant to a use-case spans multiple collections.
- Latest Collections
- Retrieve a simple list of the latest schema versions available for each NGD collection, for for a specified set.
- The latest schema version for a given collection can be automatically used for a features request.
- CRS Specification
- Short/simple versions of CRS codes can be used (eg. 27700, 4326, CRS84) instead of the full URIs.
- This applies for all crs parameters:
- crs
- bbox-crs
- filter-crs
- Filter Parameters
- Rather than writing full CQL filters, filter parameters for equality (=) can be supplied as a dictionary.
- Rather than writing a full CQL spatial filter, WKT geometries can be supplied as a separate parameter.
- Automatic Oauth2 authentication
- When CLIENT_ID (project api key) and CLIENT_SECRET (project api secret) are provided as environment variables, authentication is processed automatically via 5-minute access tokens.
- Once these environment variables are supplied, the user does not need to do any further action to authenticate their requests.
The library can be installed using pip
. It is not currently published to a repository such as PyPI but it can be installed by direct link to the latest version tag on GitHub.
$ pip install git+https://github.com/Geovation/catalyst-ngd-wrappers-python@0.1.0
Replace the version tag with the latest version. To upgrade, reinstall with the latest tag (or whichever tag you choose).
import catalyst_ngd_wrappers
collection = ['bld-fts-building', 'trn-ntwk-road', 'wtr-fts-water']
wkt = 'GEOMETRYCOLLECTION (POLYGON ((400000 400000, 400090 400050, 400050 400000, 400000 40050, 400000 400000)), LINESTRING(399990 399990, 399000 399000))'
universal_crs = 27700
limit = 300
os.environ['CLIENT_ID'] = '<YOUR_PROJECT_API_KEY>'
os.environ['CLIENT_SECRET'] = '<YOUR_PROJECT_API_SECRET>'
# Returns a hierarchical set of geojsons containing OS data for for latest versions of selected collections, for the set of search areas provided'
data = items_limit_geom_col(
collection = collection,
wkt = wkt,
use_latest_collection = True,
hierarchical_output = True
query_params = {
'wkt': universal_crs,
'filter-crs': universal_crs,
'limit': limit,
}
)