This article showcases an example web application used to request, visualize, and analyze data from Spire's API products in the Agricultural Weather context.
This web application demo is currently hosted live and can be experienced here.
The code is entirely open-source. It can be viewed and downloaded here. The code is provided only as a reference for interested developers, as-is, and without guarantees.
All weather data comes directly from Spire Weather's /forecast/point API endpoint, using the Agricultural and Basic data bundles.
Authenticating with a Spire API Token
To use this web application, you must first provide a Spire API token that is valid for Spire Weather's /forecast/point and /ows/wms/ API endpoints with the Agricultural and Basic data bundles. If you do not have such a token and would like to receive one, please contact us here. This video shows how you can use your browser's built-in password storage to save the API token for the next time you visit the page:
Drawing an Area of Interest
This web app provides functionality for drawing polygon areas on the map. The areas could, for example, represent the boundaries of a particular crop's field border, the entire property of a farmstead, or a larger encompassing region:
Viewing a Weather Point Forecast for Any Map Location
Spire Weather's /forecast/point API endpoint works with any latitude and longitude coordinate in the world. This video shows how a weather forecast can be retrieved with a simple click on the map. The code enabling the functionality in this video just takes the latitude and longitude values from the clicked map location and passes them directly into the /forecast/point API. Icons already placed on the map contain previously requested forecast data. Note that the red and yellow thresholds depicted in these graphs are set to arbitrary values, and are merely included as an example of possible functionality:
Configuring Weather WMS Layers
Spire Weather's /ows/wms API endpoint returns pre-styled, geo-referenced weather visualizations. Using a standardized Web Map Service format developed by the international Open Geospatial Consortium, the WMS data is perfect for integrating with existing map software. This video shows an example of how to add WMS layers, crop the layers to a specific region, switch between pre-configured styles (e.g. contour lines, vectors, wind barbs), and toggle the legend image unique to each style:
Change Time for WMS Layers
Spire Weather's WMS layers are also time-enabled. This video shows an example time control interface for viewing WMS layers of forecasted weather data up to 7 days in the future:
Next Steps
This demo application only shows integration with 2 data bundles from 1 of Spire Weather's offered API endpoints, /forecast/point. Spire Weather offers several other bundles of data variables, all of which can be used with the /forecast/file endpoint to retrieve GRIB2 data files for custom processing.
This demo application also lacks functionality for updating forecast data over time. A production application intended to make the most of Spire's data would likely implement this update feature, along with additional UI components such as a time slider to navigate through data in the temporal domain.
Implementing this functionality is currently left as an exercise for the reader.
For questions about how your organization can make the most of Spire's data, please feel free to contact us directly and someone from our dedicated Customer Success team will get back to you soon.