To make our data more FAIR, BGS have made a selection of our Open Data available as an API using the OGCAPI-Features standard at https://ogcapi.bgs.ac.uk/. This is targeted at academics, developers, data scientists & geospatial specialists who would like to work with our data programmatically using R/Python etc or would like a live connection to frequently updated datasets in their desktop GIS platform.
We would really appreciate your feedback or suggestions including what other data would benefit from this delivery mechanism.
The API is compatible with both ESRI ArcPro & QGIS allowing you a “live” link to the data – useful for those with frequent updates
OpenAPI specification is available through Swagger UI at - https://ogcapi.bgs.ac.uk/openapi?f=html
Data collections include:
For further documentations see OS which use the same protocol
- https://labs.os.uk/public/osngd/os-ngd-api-features/
- https://labs.os.uk/public/osngd/os-ngd-api-features/code-playground/#template-leaflet
- https://labs.os.uk/public/osngd/os-ngd-api-features/examples/items.html#filter=bbox,datetime
- https://osngd.gitbook.io/osngd/accessing-os-ngd/access-the-os-ngd-api-features
- https://osdatahub.os.uk/docs/ofa/overview
Limited to BBOX, Property Display/Filters & Sort.
Example: To get all Hydrocarbon Wells where water depth = 50 m and include attributes wellid, wellname, completion_date, water_depth_m, tvd_m, td_m
These allow full complex queries against those collections using a postgres backend.
Some example URL encoded queries:
Users don't have to URL encode the queries - the following will also work if copy & pasted into a browser:
https://ogcapi.bgs.ac.uk/collections/recentearthquakes/items?f=json&limit=100&filter=ml BETWEEN 4 AND 4.5 AND depth > 5
- Earthquakes where ml = 4.2
- Earthquakes with year = 1975 or 1990
- Earthquakes inside a defined polygon
- Earthquakes inside a defined polygon HTML response
- All earthquakes in a polygon with a ml (Richter local magnitude) between 1 & 2
- Boreholes in a polygon area where ags_log_url IS NOT NULL and length is between 20 and 50 m
- Mineral statistics for Guyana in 1975 & 1990 with erml_commodity code = Gold
In the notebook
folder we have a few example Jupyter Notebooks showing how you can interact with our data.
Follow the instructions below to install and run the demonstration Jupyter Notebook on your own machine. Alternatively, you can view the code and results in your browser. Click here for mobile-friendly version rendered by Jupyter nbviewer.
- Python 3
- A Python 3 package manager e.g. pip3, conda
The following packages should be installed via pip3
or conda
:
pip3 install -r requirements.txt
To test that the notebook runs to completion, extra packages are required:
pip3 install -r requirements-dev.txt
Run the test with:
pytest --nbval-lax notebooks\ogcapi-features-cql-owslib-earthquakes.ipynb
The demo runs in a Jupyter notebook. Start the notebook with:
jupyter notebook
A browser window will open at http://localhost:8888 with a list of available notebooks.