This directory contains examples of various geospatial data workflows after initially querying the Agrimetrics GraphQL API to obtain geospatial data. It illustrates
- Saving the outputs to common geospatial file formats such as shapefiles for usage in other software (e.g. ArcGIS/QGIS).
- Aligning geospatial data from multiple sources to enable their analysis.
- Working with geospatial and temporal data (e.g. weather time series) together.
- Analysing the queried geospatial data together in a spatial analysis.
- Leveraging various helper functions to make the analyses simpler and less prone to coding error.
The examples are executed in the R programming language within Jupyter notebooks.
- Rothamsted_static_geospatial_query_demo.ipynb — Retrieving static geospatial data over our GraphQL API, putting into a dataframe and outputting as a shape file.
- Rothamsted_timeseries_geospatial_query_demo.ipynb — Retrieving spatial and time series data together over our GraphQL API, conducting analyses and outputting as a shape file.
- Rothamsted_geospatialMeasures_demo_using_utility_functions.ipynb — Retrieving spatial and time series geospatial data from a GraphQL query and conducting analysis using various helper functions to reduce the coding burden!
- Geospatial_analysis_demo.ipynb — Example analysis of spatial interpolation of point data using Inverse Distance Weighting (IDW) on top of data downloaded from our GraphQL API.
The Jupyter notebooks can be run locally using Jupyter lab:
$ jupyter notebookThen use the Jupyter interface in your browser to navigate to one of the notebooks.
For convenience and containerisation purposes, a docker image specification has also been included. Building the image will ensure the environment is sufficient to run the above notebooks.
There are no build arguments required to build the image. Use the following to build the image and tag it agrimetrics/api-examples-jupyter.
$ docker build . -t agrimetrics/api-examples-jupyterNote: the docker image contains all of the R libraries installed by the notebooks and therefore should reduce the run time of the notebooks.
Once built, running the image can be done as follows:
$ docker run -it -e API_KEY=<insert your api key> -p 8888:8888 -v "$PWD":/home/ruser agrimetrics/api-examples-jupyterMake sure you insert your API key appropriately and ensure your current working directory is where your notebooks have been stored.
The output from doing the above should provide you with a link which, when clicked, should take you to your locally hosted Jupyter Lab. See below for an example output:
ruser@19e6699c7824:~$ jupyter notebook --ip=0.0.0.0 --port=8888
[I 22:50:57.930 NotebookApp] Serving notebooks from local directory: /home/ruser
[I 22:50:57.931 NotebookApp] 0 active kernels
[I 22:50:57.931 NotebookApp] The Jupyter Notebook is running at:
[I 22:50:57.931 NotebookApp] http://0.0.0.0:8888/?token=630a164dd6195414de671b4d1c7ad2c1721e7d2d624db047
[I 22:50:57.931 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 22:50:57.944 NotebookApp] No web browser found: could not locate runnable browser.
[C 22:50:57.945 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://0.0.0.0:8888/?token=630a164dd6195414de671b4d1c7ad2c1721e7d2d624db047