Variable Rate Application (Beta)
For a better understanding of how you can implement the API into your software see Get Started
Description
This route is used to generate variable application zones in GeoJson
to provide prescription services for fertilizer and seeding management.
When a parcel_geojson
is specified, this method generates variable application areas for the parcel. But only if the parcel is inside the field.
Endpoints
- /v1/variable-rate-zones
Method type
POST
Parameters
name | description | type | Required | Default Value |
---|---|---|---|---|
token | Your identification token | string | required | |
field_name | Name of the field | string | required | |
dst_crs | The CRS of the output geojson | string | optional | 4326 |
n_zones | Number of zones | int | required | |
layers | Array of layer json objects as a string | string | required | |
parcel_geojson | Parcel, polygon in Geojson format as a string, MUST be a "valid polygon" (closed polygon containing at least 4 points with no self itersection) | string | optional | |
files | Files to be used for clustering | file | optional |
NOTE
RULES for layers
- It is mandatory to have at least one CROP HEALTH layer
- CUSTOM layers are optional and support Shapefiles for now. (Tiff in the future)
layers examples :
layers : [{layer_1}, {layer_2}....]
where layer_1 and layer_2 can be similar to following.Types of layer objects
Crop Health Layer: Use this layer to reference to the crop health index generated by Spacesense. (mandatory)
It has the following parameters:
- type : 'crop_health'
- weight: integer
- Depending on if you want to use single date or a date range.
- Single date
- date: Date in isoformat. (isoformat :
'YYYY-MM-DD'
)- Date range
- start_date: Date in isoformat. (isoformat :
'YYYY-MM-DD'
)- end_date: Date in isoformat. (isoformat :
'YYYY-MM-DD'
)- index: crop health index to use. (ndvi, nirv, lai, chi etc). Make sure you have access to the index.
Example with single date :
{"type": "crop_health", "weight" : 3, "date":"2021-08-09", "index":"ndvi"}
Example with date range :
{"type": "crop_health", "weight" : 3, "start_date":"2021-08-09", "end_date":"2021-09-09", "index":"ndvi"}
Custom layer : Use this layer when you want to provide your own custom data in a Shapefile format (Tiff in the future).
It has the following parameters:
- type : 'custom'
- weight: integer
- filename: reference to the file name (In case of shapfile, reference the
.shp
file)- attribute: Name of the field inside the file that contains the custom data.
Example :
{"type": "custom", "weight" : 3, "filename":"homogenous_layer_VRA_Sample_1.shp", "attribute": "test_value"}
Responses
status code | description |
---|---|
200 | The request has succeeded |
400 | Bad Request or a required parameter is missing |
403 | Forbidden request |
404 | Resource was not found(No file is available for this field) |
Examples
Multiple Fields are available to test on the Demo , you can download the files to use the custom layer feature at the end of this page
Example Request without parcel
curl --location --request POST 'https://spacesense-api.ew.r.appspot.com/v1/variable-rate-zones' \
--header 'Authorization: Bearer __myToken__' \
--form 'field_name="VRA_Sample_1"' \
--form 'n_zones="5"' \
--form 'dst_crs="4326"' \
--form 'files=@"__path__/homogenous_layer_VRA_Sample_1.shx"' \
--form 'files=@"__path__/homogenous_layer_VRA_Sample_1.shp"' \
--form 'files=@"__path__/homogenous_layer_VRA_Sample_1.dbf"' \
--form 'files=@"__path__/homogenous_layer_VRA_Sample_1.prj"' \
--form 'layers="[{\"type\": \"crop_health\", \"weight\" : 3, \"date\":\"2021-03-07\", \"index\":\"ndvi\"},{\"type\": \"custom\", \"weight\" : 3, \"filename\":\"homogenous_layer_VRA_Sample_1.shp\", \"attribute\": \"test_value\"}]"'
Example Request with parcel
NOTE
The parcel must be a geojson but in a string format. So we recommend using a json.dumps to make the parcel a valid json string.
curl --location --request POST 'http://localhost:8080/v1/variable-rate-zones' \
--header 'Authorization: Bearer __myToken__' \
--form 'field_name="field_1_aoi"' \
--form 'n_zones="5"' \
--form 'layers="[{\"type\": \"crop_health\", \"weight\" : 3, \"date\":\"2021-06-23\", \"index\":\"ndvi\"}]"' \
--form 'parcel_geojson="{ \"type\": \"Feature\", \"properties\": {}, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ -93.15305471420288, 41.668536063985904 ], [ -93.15348386764526, 41.66811930984314 ], [ -93.1527328491211, 41.66774262589289 ], [ -93.15171897411346, 41.66828360747155 ], [ -93.15305471420288, 41.668536063985904 ] ] ] } }"'
Example Response
{
"crs": {
"properties": {
"name": "urn:ogc:def:crs:EPSG::32632"
},
"type": "name"
},
"features":
[{
"geometry": {
"coordinates": [
[
[516096.87713129696,5015844.765313804],
[516106.9443245859,5015815.265386641],
.....
]
],
"type": "Polygon"
},
"properties": {
"DOSE": 0.0,
"RASTER_VAL": 0.294,
"ZONE": 2
},
}]
}
Test Files
Download example files from this list: