Skip to main content

OS-PAW is the Ordnance Survey Python API Wrapper designed to make data from the OS Data Hub APIs readily accessible to python developers.

Project description

OS-PAW

OS-PAW is the Ordnance Survey Python API Wrapper designed to make data from the OS Data Hub APIs readily accessible to python developers.

Requirements

Python 3.8 or higher.

Installation

Use the package manager pip to install OS-PAW.

pip install os-paw

Usage

from os_paw.wfs_api import WFS_API

# Generate an API key from https://osdatahub.os.uk/products
API_KEY = 'my_api_key'

# Choose a Spatial Reference System
SRS = 'EPSG:27700'

# Choose an OS Web Feature Service product
TYPE_NAME = 'Zoomstack_RoadsRegional'

# Create Bounding Box
BBOX = '440000, 112000, 443000, 115000'

# Create WFS_API object and run query
wfs_api = WFS_API(api_key=API_KEY)
payload = wfs_api.get_all_features_within_bbox(type_name=TYPE_NAME,
                                               bbox=BBOX,
                                               srs=SRS)

Features

OS-PAW has improved error handling compared to requesting data directly from the OS Data Hub APIs. In particular, the user may search for a product that does not exist such as 'water' and the following message will be returned:

ValueError: "Water" is not a valid Product.
Best matches: ['WaterNetwork_WatercourseLink', 'WaterNetwork_HydroNode', 'Zoomstack_Waterlines', 'Zoomstack_Surfacewater'].

Another advantage of os-paw is that there is no upper bound on the amount of data that can be requested during one method call. The raw API places a limit at 100 features per request, but there is no such limit on the payload here. In order to save time and costs when developing, there are two extra arguments available within the get_all_features_within_bbox method:

allow_premium=False ,
max_feature_count=1000 .

The former means no premium data requests will be made and the latter means the user can restrict the amount of data returned if they happen to have picked a bounding box with a particularly high feature density.

The APIs currently accept two Spatial Reference Systems, namely British National Grid ('EPSG:27700') and World Geodetic System 1984 ('EPSG:4326').

Tests

There are currently some limited tests of the functionality of the WFS_API object. To check that these tests pass, open a command prompt and navigate to the installation of OS-PAW, then run pytest from the command line.

Limitations

Currently (12/11/2020), there is only a python wrapper for the Web Feature Service (WFS) API. If there is sufficient interest, we shall add similar functionality for the other APIs available on the OS Data Hub.

It is currently not possible to filter the results before returning the payload. For example, to return all of the schools within a bounding box, it is first necessary to return all of the buildings and then filter the resulting GeoJSON payload using your preferred method. If pre-filtering is integral to your project, you may wish to refer to the tutorial on using the raw API, or submit an issue to this project, or feel free to contribute extra functionality yourself.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

os-paw-1.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

os_paw-1.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file os-paw-1.0.1.tar.gz.

File metadata

  • Download URL: os-paw-1.0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for os-paw-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8d4a529bf0a3cbf74a23c2b80c455b370679b6a23f5271ad57dda4e91346d954
MD5 8c052d7564ba2d29a6fe8242bf6a8197
BLAKE2b-256 4967cbbc5b51a7c45bce7571eca3bf615e5af738f2ab4995779206fbdce18d26

See more details on using hashes here.

File details

Details for the file os_paw-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: os_paw-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for os_paw-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ff22c3b3ab3f6faa981e481d4e2d2718078ff4bea9d172b163ec9264e4223bb6
MD5 c99d2df8c738c41d5100c43de74c9b28
BLAKE2b-256 2de5d13bc0ae781b0e968f1adff5a71bc6e331edbae277607126581849753324

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page