Skip to main content

Layers

There is an API to get the available images and another one to get the image in different formats/configurations.

To identify an image it is necessary to (field_id, layer_name, date, operation).

  • field_id: field id
  • date: date of the image
  • layer_name: layer name
  • operation: operation to be performed on the layer.

For example: For field 1500, take the Sentinel2 layer of date 2020-11-20T00:00:00Z and perform the ndvi1 operation on it.

APIs

Dates

GET /api/layers/dates/v3?field_id=<FIELD_ID>

Response:

An object with layer types. Each type has an array of possible operations, and an array of available dates. Each operation can be applied on each of the dates in the array.

{
'code': 0,
'layers': {
"layer_name1": {
"operations": [{...}, {...}],
"dates": [{...}, {...}],
},
"layer_name2": {
"operations": [{...}, {...}],
"dates": [{...}, {...}],
}
}
}

Each element of operations has:

  • operation: is the operation code to identify the operation to the servers.
  • name: is a grouper to show to the user. It allows grouping operations of different types of layers that do the same thing. Ex: NDVI of Sentinel and Planet.

/dates/v3 object

Each object in the /dates/v3 API array dates has:

  • date: string, the date of the image
  • min: float, the minimum average ndvi within the field perimeter
  • max: float, the maximum average ndvi within the field perimeter
  • cloudy: bool, indicates if there are at least 5% cloudy pixels within the perimeter of the field. This is according to the classification given by Sentinel.

The dates elements are sorted by date, starting with the most recent.

Complete example of Response:

"layers": {
"ndvip1": {
"operations": [
{
"operation": "ndvip1",
"name": "NDVI"
}
],
"dates": [
{
"date": "2018-06-09T15:36:06Z",
"max": 65535,
"min": 36811.2
},
{
"date": "2018-06-01T15:36:02Z",
"max": 65535,
"min": 25619.5
},
{
"date": "2018-05-24T15:35:23Z",
"max": 65535,
"min": 40151.7
}
]
},
"Sentinel2": {
"operations": [
{
"operation": "ndvi1",
"name": "NDVI"
},
{
"operation": "gndvi1",
"name": "GNDVI"
},
{
"operation": "rgb1",
"name": "Visible"
},
{
"operation": "msavi2",
"name": "MSAVI2"
},
{
"operation": "ndre",
"name": "NDRE"
}
],
"dates": [
{
"date": "2020-06-10T00:00:00Z",
"max": 0.49,
"cloudy": true,
"min": -0.32
},
{
"date": "2020-06-05T00:00:00Z",
"max": 0.8,
"cloudy": false,
"min": -0.2
},
{
"date": "2020-05-31T00:00:00Z",
"max": 0.85,
"cloudy": false,
"min": 0.1
}
]
},
"siembra": {
"operations": [
{
"operation": "siembra",
"name": "siembra"
}
],
"dates": [
{
"date": "2019-12-13T15:15:38Z",
"max": 552257.969844542,
"metadata": {
"info": {
"cropSeason": "2019",
"cropName": "SOYBEANS"
}
},
"min": 358382.068724971
}
]
}

}

Geoserver

GET /api/geoserver/v2

URL parameters:

  • field_id: field ID
  • layer_name: layer image provider name.
  • operation: operation code.
  • date: date with YYYYY-MM-DDTHH:mm:ssZ format
  • format:
    • image/png: PNG as RGBA.
    • image/tiff: GeoTiff.
    • image/encoded: PNG as RGB. The data is sent in 16bits where the first 8bits are in the first layer of the PNG (R) and the second 8bits are in the second layer (G). The third layer (B) has all zeros.

      This parameter is optional. If not included, the default is "image/png".

  • epsg: Number of EPSGs to reproject the image.

    This parameter is optional. If not included, the default depends on the layer type.

  • bbox:
    • Coordinates of the Bounding Box of the desired image to reproject. The coordinates must be comma separated in the order: xmin,ymin,xmax,ymax. They must also be in the EPSG of the final image. (It is recommended to use the EPSG parameter).

      This parameter is optional. If it is not included, the final image corresponds to the BoundingBox of the field with a buffer of 2 pixels. If included, it is mandatory to include also width and height.

  • width: Number of pixels of the width of the final image.

    This parameter is optional. If included, it is mandatory to include also bbox and height.

  • height: Number of pixels of the height of the final image.

    This parameter is optional. If included, it is mandatory to include also bbox and width.

  • transparent:
    • true: a mask is applied on the image to remove pixels outside the field.
      • in case of PNG, alpha pixels are set to 0 (transparent).
      • in case of TIFF, pixels are set to NODATA.
    • false: the mask is not applied.

      This parameter is optional. If not included, the default is false

Custom scale templates

GET /api/layers/scale_template

Returns the templates of the user's custom scales.

Full response example:

{
"scale_templates": [
{
"palette": "cb-RdYlGn",
"range_min": 0.17,
"type_distribution": "quantiles",
"template_name": "personalizada 1",
"cant_intervals": 5,
"scale_template_id": 1102,
"hierarchy": [
"Imágenes"
],
"colors_scale": {
"colors": [
[
215,
25,
28
],
[
253,
174,
97
],
[
255,
255,
191
],
[
166,
217,
106
],
[
26,
150,
65
]
],
"scale": [
0.41747474747474717,
0.4669696969696966,
0.502323232323232,
0.5588888888888889
]
},
"layer_name": "Sentinel2",
"range_max": 0.87,
"operation": "ndvi1"
},
{
"palette": "cb-Spectral",
"range_min": -652.07,
"type_distribution": "equidistant",
"template_name": "ls_personalizada_1",
"cant_intervals": 3,
"scale_template_id": 1139,
"hierarchy": [
"Actividades",
"Prescripciones"
],
"colors_scale": {
"colors": [
[
153,
213,
148
],
[
255,
255,
191
],
[
252,
141,
89
]
],
"scale": [
-434.3799999999992,
-210.09333333333186
]
},
"layer_name": "Urea",
"range_max": 1,
"operation": "Urea"
},
],
"code": "RETRIEVED_SCALE_TEMPLETES"
}

Available images

Avaliable images can be consuted through Dates API

Sentinel2

If no reprojection is requested, the resolution of these images is 10x10 metres in the WGS84 / UTM projection.

Each image has 2 pixels of margin around the perimeter of the field.

The operations available on this layer provider are:

  • ndvi1: NDVI
  • gndvi1: GNDVI
  • rgb1: RGB
  • msavi2: MSAVI2
  • ndre: NDRE

tiff images.

For the operations ndvi1, gndvi1, msavi2 and ndre a single band GeoTiff is delivered. Each pixel is the index value indicated by the operation in float32. The NODATA value of these is nan.

In the case of rgb1, a 3-band GeoTiff is delivered where each pixel is a Byte (uint8). Their NODATA value is 0.

Creating New Layers

This is a two step process:

  • In the first one, you upload a file for our API to analize and return information about it.
  • In the second step, with this info, the user indicates column, units and more details; and calls our second endpoint to process the file and create the layer.

Upload files

POST /files
Body (Form):
file: zip with files.
  • Possible formats: csv, xlsx, txt, shp(with asociated required files)

    • CSV Example:

          lat;lon;variable_1;var_2
      40.35715828;-89.92172667;35010;25
      40.35715828;-89.92172375;35010;15
      40.35715825;-89.92172082;35005;10
    • XLSX / XLS Example:

      latlonvariable_1var_2
      40,35715828-89,921726673501025
      40,35715828-89,921723753501015
      40,35715825-89,921720823500510
  • Valid geometries: {"Point", "Polygon", "MultiPolygon"}

  • Possible responses

    • 400 -
    { "error_code": "ERROR_ARCHIVO" }

    Your file is not right

    • 200 -

    {"data":
    {"not_found": True,
    "lote": `WKT DEL ARCHIVO`}
    }

    this means that your files do not match any of the users' fields
  • 200 -


{"data": {
"redis_id": redis_id,
"lote_id": field_id,
"columns": [list of columns],
"stats": ,
"histograms": ,
}}


Process files

POST /raster
Body (json):
redis_id: HASH from previous endpoint
date: layer date, format: "YYYY-MM-DD HH:MM:SS"
data: settings object
lote_id: field id

The settings object can be made this way:

  • for each key that is sent a layer will be created
  • each key is the name of the column on which you want to build the layer
  • each value is an object that has the settings for the new layer:
    • id_layer: id for tipo_capa from the layer you want to create
    • mean: (float o null) nueva mean value
    • min: (float o null) minimum value (outliers)
    • max: (float o null) minimum value (outliers)
    • meta:
      • numerador_media: numerator unit
      • denominador_media: denominator unit

Generate raster layer from interpolation of points by "kriging"

On many occasions we have data obtained at different points of a field. In that case, it is easier to view the data in a raster layer format rather than in isolated points.

Fortunately we can interpolate the points through kriging to generate a raster layer from these.

To achieve this, a parameter "interpolation_type" with the value "kriging" shall be sent in the settings of the desired layer, which is found within the settings object.

Example of json sent in the /raster endpoint body:

{
redis_id: "ABCD1234",
lote_id: "123456",
date: "2022-12-13 00:00:00",
data: {
capa1: {
id_layer: 419,
interpolation_type: "kriging",
mean: 12.34,
min: 6,
max: 34.56,
meta: {
numerador_media: "kg",
denominador_media: "ha",
}
}
}
}

Layer types

idnombre
1ndvi1
2ndvip1
3gndvi1
4gndvip1
5rinde
6rgb1
7rgbp1
8altimetria
9siembra
10herbicida
11fungicida
12insecticida
13fertilizante
14enmienda
15profundidad_suelo
17Densidad_20
22margen_bruto
24ndvi0.8
25vigor planta
26tcari/osavi
27NDRE
29RGB0.8
31Sentinel2
32Planet
34aplicación
35humedad
36Electroconductividad_70
37Electroconductividad_150
39siembra_vel_avance
40siembra_var
41siembra_fecha
42rinde_hum
43rinde_vel_avance
44rinde_fecha
45MO_20
46MO_30
47MO_40
48MO_50
49MO_60
50MO_70
51MO_80
52MO_90
53MO_100
54MO_110
55MO_120
56MO_130
57MO_140
58MO_150
59N_20
60N_30
61N_40
62N_50
63N_60
64N_70
65N_80
66N_90
67N_100
68N_110
69N_120
70N_130
71N_140
72N_150
73P_20
74P_30
75P_40
76P_50
77P_60
78P_70
79P_80
80P_90
81P_100
82P_110
83P_120
84P_130
85P_140
86P_150
87K_20
88K_30
89K_40
90K_50
91K_60
92K_70
93K_80
94K_90
95K_100
96K_110
97K_120
98K_130
99K_140
100K_150
101S_20
102S_30
103S_40
104S_50
105S_60
106S_70
107S_80
108S_90
109S_100
110S_110
111S_120
112S_130
113S_140
114S_150
115PH_20
116PH_30
117PH_40
118PH_50
119PH_60
120PH_70
121PH_80
122PH_90
123PH_100
124PH_110
125PH_120
126PH_130
127PH_140
128PH_150
129Ca_20
130Ca_30
131Ca_40
132Ca_50
133Ca_60
134Ca_70
135Ca_80
136Ca_90
137Ca_100
138Ca_110
139Ca_120
140Ca_130
141Ca_140
142Ca_150
143Mg_20
144Mg_30
145Mg_40
146Mg_50
147Mg_60
148Mg_70
149Mg_80
150Mg_90
151Mg_100
152Mg_110
153Mg_120
154Mg_130
155Mg_140
156Mg_150
157Na_20
158Na_30
159Na_40
160Na_50
161Na_60
162Na_70
163Na_80
164Na_90
165Na_100
166Na_110
167Na_120
168Na_130
169Na_140
170Na_150
171Electroconductividad_30
172Electroconductividad_40
173Electroconductividad_60
174Electroconductividad_90
175Electroconductividad_100
176Electroconductividad_120
177Electroconductividad_130
178Electroconductividad_140
179Arena_20
180Arena_30
181Arena_40
182Arena_50
183Arena_60
184Arena_70
185Arena_80
186Arena_90
187Arena_100
188Arena_110
189Arena_120
190Arena_130
191Arena_140
192Arena_150
193Arcilla_20
194Arcilla_30
195Arcilla_40
196Arcilla_50
197Arcilla_60
198Arcilla_70
199Arcilla_80
200Arcilla_90
201Arcilla_100
202Arcilla_110
203Arcilla_120
204Arcilla_130
205Arcilla_140
206Arcilla_150
207Limo_20
208Limo_30
209Limo_40
210Limo_50
211Limo_60
212Limo_70
213Limo_80
214Limo_90
215Limo_100
216Limo_110
217Limo_120
218Limo_130
219Limo_140
220Limo_150
221Densidad_30
222Densidad_40
223Densidad_50
224Densidad_60
225Densidad_70
226Densidad_80
227Densidad_90
228Densidad_100
229Densidad_110
230Densidad_120
231Densidad_130
232Densidad_140
233Densidad_150
234aplicación_fecha
235aplicación_hum
236aplicación_presion
237aplicación_temp
238aplicación_vel_avance
239costo
240ingreso
390Electroconductividad_20
391Electroconductividad_50
392Electroconductividad_80
393Electroconductividad_110