Skip to main content

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

Release files for os-paw 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for os-paw 1.0.1
File Size Uploaded
os-paw-1.0.1.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for os-paw 1.0.1
File Interpreter ABI Platform
os_paw-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / os-paw-1.0.1.tar.gz

Download URL os-paw-1.0.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8d4a529bf0a3cbf74a23c2b80c455b370679b6a23f5271ad57dda4e91346d954
BLAKE2b-256 checksum
How to use checksums
4967cbbc5b51a7c45bce7571eca3bf615e5af738f2ab4995779206fbdce18d26
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / os_paw-1.0.1-py3-none-any.whl

Download URL os_paw-1.0.1-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff22c3b3ab3f6faa981e481d4e2d2718078ff4bea9d172b163ec9264e4223bb6
BLAKE2b-256 checksum
How to use checksums
2de5d13bc0ae781b0e968f1adff5a71bc6e331edbae277607126581849753324
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page