Formatting coordinates for API requests
The Climate Engine API allows two ways of passing geometries to API endpoints to make data requests: 1) coordinates and 2) Google Earth Engine Feature Collections. In many cases, passing coordinates will be more flexible than uploading your data to Google Earth Engine and this article is intended to help you to return data from the API successfully. As such, this article pertains to the coordinates endpoints such as timeseries/native/coordinates.
Currently, the Climate Engine API supports geometries of Point, MultiPoint, Polygon, and MultiPolygon and does not explicitly require you to pass the name of the geometry used, only the coordinates. Below are examples of how to format your coordinates for each of the aforementioned geometry types when making requests.
- Point:
- [[-121.61,38.78]]
- Note: Users can also return data for multiple Points in a single request by passing a list of points formatted like [[-121.61,38.78], [-122.71,39.74]]
- Polygon:
- [[[-121.61,38.78],[-121.52,38.78],[-121.52,38.83],[-121.61,38.83],[-121.61,38.78]]]
- Note: Users can also return data for multiple Polygons in a single request by passing a list of points formatted like as [[[-121.61,38.78],[-121.52,38.78],[-121.52,38.83],[-121.61,38.83],[-121.61,38.78]], [[-122.61,39.78], [-122.52,39.78], [-122.52, 39.83], [-122.61,39.83], [-122.61,39.78]]]
- MultiPolygon:
- [[[[-104.98, 40.72], [-104.92, 40.77], [-105.03, 40.80], [-105.13, 40.70]]], [[[-104.89, 40.78], [-104.86, 40.726], [-104.83276495279011, 40.76]]]]
Note: For especially long lists of coordinates that return an error of 413: Request Entity Too Large, try using a POST request rather than a GET request.
If you are having difficulty returning data for your coordinates, the Swagger user interface available at api.climateengine.org can be a useful way to troubleshoot. For each API endpoint there is an example set of coordinates for you to test. In general, any of the above example coordinates can be input into the 'coordinates' argument to test the endpoints, assuming the selected dataset intersects the coordinates provided.