import requests
import rasterio
import rasterio.plot
import folium
from rasterio.warp import calculate_default_transform, reproject, Resampling
from requests.auth import HTTPBasicAuth
Evapotraspiration Map
In this part we will focus on two ednpoint:
- “AFS/EvapotraspirationMap” endpoint, which allow the user to get the latest map of the evapotraspiration in tiff format
- “AFS/EvapotraspirationMapGeojson” endpoint, which allow the user to get the latest map of the evapotraspiration in geojson format
EvapotraspirationMap
Python
In this example we will test the EvapotraspirationMap which allow the user to get the latest evapotraspiration map available for the Area of Interest in tiff format
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
Load Libraries
Setting of the API
# Define the API parameters
="1"
fieldnumber="none"
action="onelastmonth"
filterTime
# Define the url of the endpoint
= "https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapNew?"
api_endpoint
# Define the api url
=api_endpoint+"fieldnumber="+fieldnumber+"&action="+action+"&filterTime="+filterTime
api_url
# Set the useremail & Password
="useremail"
USEREMAIL="apikey"
APIKEY
# Set the geojson file to send
= "county.geojson" geojson_file_path
Define python function
def convert_to_wgs84(input_raster_path, output_raster_path):
# Open the input raster
with rasterio.open(input_raster_path) as src:
# Define the target CRS (WGS 84 - EPSG:4326)
= 'EPSG:4326'
target_crs
# Get the affine transformation and dimensions of the new raster
= calculate_default_transform(src.crs, target_crs, src.width, src.height, *src.bounds)
transform, width, height
# Create the options for reprojection
= src.meta.copy()
kwargs
kwargs.update({'crs': target_crs,
'transform': transform,
'width': width,
'height': height
})
# Reproject the raster to WGS 84
with rasterio.open(output_raster_path, 'w', **kwargs) as dst:
for i in range(1, src.count + 1):
reproject(=rasterio.band(src, i),
source=rasterio.band(dst, i),
destination=src.transform,
src_transform=src.crs,
src_crs=transform,
dst_transform=target_crs,
dst_crs=Resampling.nearest
resampling )
def post_request_with_geojson(geojson_file_path, api_url):
# Leggi il file GeoJSON
with open(geojson_file_path, 'r') as file:
= file.read()
geojson_data
# Specifica l'header per la POST request
= {'Content-Type': 'application/json'}
headers
# Effettua la POST request
= requests.post(api_url,
response =geojson_data,
data=headers,
headers=HTTPBasicAuth(USEREMAIL, APIKEY))
auth
if response.status_code == 200:
# Save the response as a temporary raster file
= "temp_raster.tif"
temp_raster_path with open(temp_raster_path, 'wb') as temp_raster_file:
temp_raster_file.write(response.content)
# Convert the raster to WGS 84 (EPSG:4326)
= "temp_raster_wgs84.tif"
wgs84_raster_path
convert_to_wgs84(temp_raster_path, wgs84_raster_path)
# Open the WGS 84 raster using rasterio
= rasterio.open(wgs84_raster_path)
wgs84_raster
# Read the image as a numpy array
= wgs84_raster.read(1)
data
# Get the extent of the image
= wgs84_raster.bounds
xmin, ymin, xmax, ymax
# Create a folium map centered at the center of the extent of the image
= [(ymin+ymax)/2, (xmin+xmax)/2]
center = folium.Map(location=center, zoom_start=16)
m
# Add the tif file as a raster layer
= folium.raster_layers.ImageOverlay(
overlay =data,
image=[[ymin, xmin], [ymax, xmax]],
bounds=lambda x: (0, 0, 0, x/255),
colormap=True)
mercator_project
overlay.add_to(m)
# Visualize the map
return m
else:
print("Error during the request.")
return None
# Make the POST request
= post_request_with_geojson(geojson_file_path, api_url)
m
# Visualize the results
m
R
In this example we will test the EvapotraspirationMap which allow the user to get the latest evapotraspiration map available for the Area of Interest in tiff format
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
# import libraries
library(tictoc)
library(httr)
library(gt)
library(tidyverse)
library(raster)
library(mapview)
# Define the api parameters
="1"
fieldnumber="none"
action="onelastmonth"
filterTime
# Define the url of the API
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapNew?"
api_endpoint
# Define the API call
=paste0(api_endpoint, "fieldnumber=", fieldnumber, "&action=", action, "&filterTime=", filterTime)
api_url
# Set the useremail & Password
="useremail"
USEREMAIL="apikey"
APIKEY
# Path to the GeoJSON file
= "county.geojson"
file_path_to_geojson
# Get the start time to API Call
tic()
# Make the POST request
<- POST(
r
api_url,::authenticate(
httruser = Sys.getenv(USEREMAIL),
password = Sys.getenv(APIKEY)
),body=httr::upload_file(file_path_to_geojson)
)
# Print out the seconds needed to get the satellite image
print("The API needed:")
[1] "The API needed:"
toc()
2.43 sec elapsed
# Get the status of the request
status_code(r)
[1] 200
# Visulize the vegetation index
<-readBin(r$content, what = "raw", n=length(r$content))
bin_raster
writeBin(bin_raster, con = "raster.tif")
<- raster::raster("raster.tif")
raster
::mapview(raster, layer.name="Evapotraspiration") mapview
Node.js
In this example we will test the EvapotraspirationMap which allow the user to get the latest evapotraspiration map available for the Area of Interest in tiff format
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojsonFilePath (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
// load libraries
const axios = require('axios');
const fs = require('fs');
// Set the username & API key
const username = 'XXXXXXXXXXXXXXXXX';
const password = 'XXXXXXXXXXXXXXXXXXX';
// Set the api parameters
const fieldnumber="1";
const action="none";
const filterTime='onelastmonth';
// Set api url
const api_url = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapNew?';
// Set api endpoint
const apiendpoint = api_url.concat("fieldnumber=", fieldnumber, "&action=", action, "&filterTime=",filterTime);
// Set the path to the local GeoJson that you want to use
const geojsonFilePath = './county.geojson';
// Set the path to save the raster that we will recive
const rasterFilePath = './file.tif';
async function makePostRequest() {
const geojsonFile = fs.readFileSync(geojsonFilePath, 'utf8');
const authHeader = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
try {
const response = await axios.post(apiendpoint, geojsonFile, {
headers: {
'Content-Type': 'application/json',
'Authorization': authHeader,
,
}responseType: 'arraybuffer',
;
})
.writeFileSync(rasterFilePath, response.data);
fs
console.log('The raster file was locally saved', rasterFilePath);
catch (error) {
} console.error('An error occurred:', error.message);
}
}
makePostRequest();
Java
In this example we will test the EvapotraspirationMap which allow the user to get the latest evapotraspiration map available for the Area of Interest in tiff format
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojsonFilePath (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
public class VegetationIndex {
public static void main(String[] args) {
String apiUrl = "https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMap?fieldnumber=1&action=new&filterTime=onelastmonth";
String username = "XXXXXXXX";
String password = "XXXXXXXX";
String geojsonFilePath = "county.geojson";
String geojsonFile = "";
try {
= new String(Files.readAllBytes(Paths.get(geojsonFilePath)));
geojsonFile } catch (IOException e) {
.printStackTrace();
e}
String authHeader = "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
try {
URL url = new URL(apiUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", authHeader);
conn.setDoOutput(true);
conn
OutputStream os = conn.getOutputStream();
.write(geojsonFile.getBytes());
os.flush();
os
// Gestisci la risposta
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
// Salva il file raster ottenuto in risposta
String rasterFilePath = "raster_file.tif"; // Sostituisci con il percorso in cui vuoi salvare il file raster
try (InputStream is = conn.getInputStream(); FileOutputStream fos = new FileOutputStream(rasterFilePath)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = is.read(buffer)) != -1) {
.write(buffer, 0, bytesRead);
fos}
}
System.out.println("The raster file was saved correctly: " + rasterFilePath);
} else {
System.out.println("An error occured: " + conn.getResponseMessage());
}
.disconnect();
conn} catch (IOException e) {
.printStackTrace();
e}
}
}
EvapotraspirationMapGeojson
Python
In this example we will test the EvapotraspirationMapGeojson which allow the user to get the latest vegetation index available for the Area of Interest in gejson format
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
# Load the libraries
import requests
import fiona
import geopandas as gpd
from requests.auth import HTTPBasicAuth
# Set API Parameter
="1"
fieldnumber="none"
action="onelastmonth"
filterTime
# Define the url of the endpoint
= "https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapGeojsonNew?"
api_endpoint
# Define the api url
=api_endpoint+"fieldnumber="+fieldnumber+"&action="+action+"&filterTime="+filterTime
url
# Set the useremail & Password
="useremail"
USEREMAIL="apikey""
APIKEY
# Path to the GeoJSON file
= "county.geojson"
file_path_to_geojson
# Read the GeoJSON file contents
with open(file_path_to_geojson, "r") as file:
= file.read()
geojson_data
# Set the headers for the request
= {
headers "Content-Type": "application/json"
}
# Make the POST request with the GeoJSON data as the request body
= requests.post(url,
response =geojson_data,
data=headers,
headers=HTTPBasicAuth(USEREMAIL, APIKEY))
auth
= bytes(response.content)
b
with fiona.BytesCollection(b) as f:
= f.crs
crs = gpd.GeoDataFrame.from_features(f, crs=crs)
gdf
# Visualize the data
"Data_2023.07.19") gdf.explore(
R
In this example we will test the EvapotraspirationMapGeojson which allow the user to get the latest vegetation index available for the Area of Interest in gejson format
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
# Load the libraries
library(tictoc)
library(httr)
library(geojsonio)
library(mapview)
# Define the api parameters
="1"
fieldnumber="none"
action="onelastmonth"
filterTime
# Define the url of the API
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapGeojsonNew?"
api_endpoint
# Define the API call
=paste0(api_endpoint, "fieldnumber=",fieldnumber, "&action=",action, "&filterTime=", filterTime)
url
# Set the useremail & Password
="useremail"
USEREMAIL="apikey"
APIKEY
# Path to the GeoJSON file
= "county.geojson"
file_path_to_geojson
# Get the start time to API Call
tic()
# Make the POST request
<- POST(
api_call
url,::authenticate(
httruser = Sys.getenv(USEREMAIL),
password = Sys.getenv(APIKEY)
),body=httr::upload_file(file_path_to_geojson)
)
# Print out the seconds needed to create the prescription map
print("The API needed:")
[1] "The API needed:"
toc()
2.22 sec elapsed
# Visualize the prescription map
<- content(api_call, as = "text", type = "application/geo+json")
vegetation_index <-geojson_sp(vegetation_index)
vegetation_indexmapview(vegetation_index, zcol=names(vegetation_index)[1], layer.name="Evapotraspiration 2023.07.19")
Node.js
In this example we will test the EvapotraspirationMapGeojson which allow the user to get the latest vegetation index available for the Area of Interest in gejson format
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
// Load Libraries
const fs = require('fs');
const axios = require('axios');
// Set the useremail & passowrd
const useremail = 'XXXXXXXXXXXXX';
const apikey = 'XXXXXXXXXXXXX';
// Set the api parameters
const fieldnumber="1";
const action="none";
const filterTime='onelastmonth';
// Set api url
const api_url = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapGeojsonNew?';
// Set api endpoint
const apiEndpoint = api_url.concat("fieldnumber=",fieldnumber, "&action=", action, "&filterTime=",filterTime);
// Set path to load the geojson to send as body of POST request to the API
const file_path_to_geojson = './county.geojson';
// Set path to save the geojson prescription map
const outputFilePath = './result.geojson';
async () => {
(try {
const geojsonContent = await fs.promises.readFile(file_path_to_geojson, 'utf8');
const geojsonObject = JSON.parse(geojsonContent);
const authHeader = `Basic ${Buffer.from(`${useremail}:${apikey}`).toString('base64')}`;
const response = await axios.post(apiEndpoint, geojsonObject, {
headers: {
'Content-Type': 'application/json',
'Authorization': authHeader
};
})
const resultGeoJSON = response.data;
console.log('Answer From the API:', resultGeoJSON);
await fs.promises.writeFile(outputFilePath, JSON.stringify(resultGeoJSON, null, 2), 'utf8');
catch (err) {
} console.error('Error:', err.message);
}; })()
EvapotraspirationTemporalVarationJson
Python
In this example we will test the EvapotraspirationTemporalVariationJson which allow the user to get a json with the temporal variation of the vegetation index.
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
# Load the libraries
import requests
import json
import pandas as pd
from requests.auth import HTTPBasicAuth
# Set API parameter
="1"
fieldnumber="none"
action
# Define the url of the API
= "https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationTemporalVariationJsonNew?"
url
# Define the API endpoint
= url+"fieldnumber="+fieldnumber+"&action="action
url
# Set the useremail & Password
="XXXXXXXXXXXX"
USEREMAIL="XXXXXXX"
APIKEY
# Path to the GeoJSON file
= "county.geojson"
file_path_to_geojson
# Read the GeoJSON file contents
with open(file_path_to_geojson, "r") as file:
= file.read()
geojson_data
# Set the headers for the request
= {
headers "Content-Type": "application/json"
}
# Make the POST request with the GeoJSON data as the request body
= requests.post(url,
response =geojson_data,
data=headers,
headers=HTTPBasicAuth(USEREMAIL, APIKEY))
auth
=response.content
response_bytes
= response_bytes.decode('utf-8')
response_str
# Parse the JSON string
= json.loads(response_str)
data
# Create a DataFrame
= pd.DataFrame(data)
df
df.head()
R
In this example we will test the EvapotraspirationTemporalVariationJson which allow the user to get a json with the temporal variation of the vegetation index.
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
# Load the libraries
library(tictoc)
library(httr)
library(geojsonio)
library(mapview)
# Set API parameter
="1"
fieldnumber="none"
action
# Define the url of the API
= paste0("https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationTemporalVariationJsonNew?")
url
# Set API endpoint
=paste0(url,"fieldnumber=",fieldnumber,"&action=",action)
url
# Set the useremail & Password
="useremail"
USEREMAIL="apikey"
APIKEY
# Path to the GeoJSON file
= "county.geojson"
file_path_to_geojson
# Get the start time to API Call
tic()
# Make the POST request
<- POST(
api_call
url,::authenticate(
httruser = Sys.getenv(USEREMAIL),
password = Sys.getenv(APIKEY)
),body=httr::upload_file(file_path_to_geojson)
)
# Print out the seconds needed to create the prescription map
print("The API needed:")
[1] "The API needed:"
toc()
2.27 sec elapsed
# Visualize the prescription map
<- httr::content(api_call, as = "text", type = "application/json", encoding="UTF-8")
cont <-jsonlite::fromJSON(cont) %>% as.data.frame
cont cont
layer
1 1.8870e-01
2 2.2140e-01
3 4.1600e-02
4 1.7150e-01
5 5.3500e-01
6 2.6000e-03
7 1.5800e-02
8 1.3800e-01
9 1.7000e-03
10 2.2000e-03
11 7.7000e-03
12 1.1860e-01
13 3.0000e-03
14 2.5600e-02
15 3.5000e-03
16 6.0000e-03
17 1.0000e-03
18 3.4000e-03
19 3.1000e-03
20 3.1000e-03
21 5.1800e-02
22 1.5900e-01
23 5.1000e-02
24 3.7700e-02
25 1.3440e-01
26 3.8830e-01
27 1.1300e-02
28 5.4000e-03
29 2.7000e-03
30 1.4000e-03
31 3.0000e-04
32 3.0000e-04
33 9.0000e-04
34 3.8000e-03
35 5.8980e-01
36 4.6000e-03
37 2.2000e-03
38 2.6000e-03
39 6.6000e-03
40 2.2500e-02
41 1.2900e-02
42 4.4000e-03
43 3.5000e-03
44 9.4000e-03
45 3.3400e-02
46 1.4930e-01
47 5.2410e-01
48 4.1000e-03
49 4.7000e-03
50 5.9000e-03
51 3.1000e-03
52 1.8000e-03
53 1.6000e-03
54 1.2000e-03
55 1.2000e-03
56 8.0000e-04
57 1.1000e-03
58 3.7000e-03
59 1.6500e-02
60 3.8200e-01
61 5.3410e-01
62 9.6910e-01
63 1.1090e-01
64 3.4090e-01
65 1.0898e+00
66 2.5040e-01
67 2.9000e-03
68 1.5000e-03
69 1.9000e-03
70 1.2000e-03
71 3.0000e-04
72 3.0000e-04
73 5.0000e-04
74 6.0000e-04
75 5.0000e-04
76 2.0000e-04
77 8.0000e-04
78 1.2100e-02
79 1.3930e-01
80 3.5290e-01
81 3.0100e-01
82 4.6500e-02
83 6.1000e-03
84 1.4000e-03
85 2.2000e-03
86 5.3000e-03
87 4.6000e-03
88 3.7000e-03
89 3.3000e-03
90 1.5000e-03
91 1.0000e-03
92 2.0000e-03
93 1.9000e-03
94 1.9000e-03
95 2.0000e-03
96 4.5000e-03
97 2.5800e-02
98 8.2600e-02
99 1.2610e-01
100 1.2380e-01
101 1.5020e-01
102 8.1400e-02
103 2.4300e-02
104 9.3900e-02
105 4.8730e-01
106 1.3730e-01
107 2.8600e-02
108 1.6390e-01
109 1.1250e-01
110 1.7600e-02
111 1.3000e-03
112 1.0000e-03
113 1.3000e-03
114 5.0000e-04
115 1.0000e-04
116 1.0000e-04
117 2.0000e-04
118 2.0000e-04
119 1.0000e-04
120 1.0000e-04
121 2.0000e-04
122 2.7000e-03
123 4.7400e-02
124 1.1990e-01
125 1.0350e-01
126 5.9700e-02
127 4.8900e-02
128 6.2400e-02
129 1.8200e-01
130 1.3180e-01
131 6.5200e-02
132 2.8100e-02
133 1.1700e-02
134 3.5000e-03
135 3.0000e-04
136 5.0000e-04
137 2.0000e-03
138 5.5000e-03
139 4.1000e-03
140 2.8000e-03
141 1.5000e-03
142 1.4000e-03
143 1.1000e-03
144 1.6000e-03
145 2.4000e-03
146 3.1000e-03
147 1.7000e-03
148 1.5000e-03
149 3.0000e-03
150 5.0000e-03
151 4.9000e-03
152 2.0000e-03
153 9.0000e-04
154 9.0000e-04
155 8.0000e-04
156 2.0000e-03
157 2.3300e-02
158 2.4200e-02
159 5.0000e-03
160 3.9000e-03
161 2.2000e-03
162 1.0000e-03
163 6.0000e-04
164 6.0000e-04
165 5.0000e-04
166 1.0000e-04
167 1.0000e-04
168 1.0000e-04
169 1.0000e-04
170 0.0000e+00
171 0.0000e+00
172 1.0000e-04
173 1.0000e-04
174 2.0000e-03
175 5.8800e-02
176 1.1850e-01
177 1.4680e-01
178 1.5110e-01
179 1.1860e-01
180 1.1080e-01
181 1.3680e-01
182 7.9900e-02
183 4.1900e-02
184 1.8800e-02
185 1.1500e-02
186 6.0000e-03
187 4.1000e-03
188 6.8000e-03
189 6.2000e-03
190 5.8000e-03
191 2.0000e-03
192 5.0000e-04
193 7.0000e-04
194 2.3000e-03
195 5.8000e-03
196 4.3000e-03
197 2.6000e-03
198 1.4000e-03
199 1.6000e-03
200 2.2000e-03
201 2.7000e-03
202 3.1000e-03
203 2.4000e-03
204 1.5000e-03
205 1.1000e-03
206 7.0000e-04
207 6.0000e-04
208 8.0000e-04
209 6.0000e-04
210 3.0000e-04
211 2.0000e-04
212 2.0000e-04
213 2.0000e-04
214 8.0000e-04
215 8.0000e-04
216 4.0000e-04
217 4.0000e-04
218 5.0000e-04
219 5.0000e-04
220 6.0000e-04
221 5.0000e-04
222 3.0000e-04
223 1.0000e-04
224 1.0000e-04
225 0.0000e+00
226 0.0000e+00
227 6.6143e-06
228 0.0000e+00
229 1.0000e-04
230 2.0000e-04
231 4.5000e-03
232 5.4500e-02
233 1.0020e-01
234 1.6970e-01
235 2.2390e-01
236 1.8450e-01
237 1.8250e-01
238 2.2710e-01
239 1.2300e-01
240 3.8800e-02
241 1.7400e-02
242 1.0000e-02
243 4.6000e-03
244 4.1000e-03
245 2.7000e-03
246 2.4000e-03
247 2.0000e-03
248 3.0000e-03
249 5.1000e-03
250 4.2000e-03
251 4.3000e-03
252 2.1000e-03
253 1.1000e-03
254 1.7000e-03
255 4.8000e-03
256 8.0000e-03
257 5.1000e-03
258 3.0000e-03
259 1.2000e-03
260 1.1000e-03
261 1.5000e-03
262 1.7000e-03
263 1.0000e-03
264 9.0000e-04
265 7.0000e-04
266 6.0000e-04
267 4.0000e-04
268 4.0000e-04
269 5.0000e-04
270 4.0000e-04
271 2.0000e-04
272 1.0000e-04
273 2.0000e-04
274 2.0000e-04
275 4.0000e-04
276 3.0000e-04
277 2.0000e-04
278 1.0000e-04
279 2.0000e-04
280 6.0000e-04
281 7.0000e-04
282 5.0000e-04
283 2.0000e-04
284 1.0000e-04
285 1.0000e-04
286 1.0000e-04
287 0.0000e+00
288 0.0000e+00
289 1.0000e-04
290 1.0000e-04
291 3.0000e-04
292 9.4000e-03
293 7.2200e-02
294 1.2100e-01
295 1.6080e-01
296 1.5220e-01
297 1.2250e-01
298 6.5620e-01
299 3.2500e-01
300 8.1800e-02
301 6.3900e-02
302 3.7400e-02
303 1.4800e-02
304 6.6000e-03
305 3.9000e-03
306 2.4000e-03
307 2.3000e-03
308 3.8000e-03
309 2.0000e-03
310 1.3000e-03
311 1.6000e-03
312 2.6000e-03
313 3.3000e-03
314 2.5000e-03
315 2.7000e-03
316 2.0000e-03
317 1.6000e-03
318 2.1000e-03
319 5.0000e-03
320 5.0000e-03
321 3.9000e-03
322 2.6000e-03
323 5.0000e-04
324 7.0000e-04
325 1.1000e-03
326 5.0000e-04
327 2.0000e-04
328 5.0000e-04
329 5.0000e-04
330 5.0000e-04
331 7.0000e-04
332 9.0000e-04
333 1.1000e-03
334 1.1000e-03
335 7.0000e-04
336 3.0000e-04
337 2.0000e-04
338 2.0000e-04
339 4.0000e-04
340 3.0000e-04
341 3.0000e-04
342 2.0000e-04
343 3.0000e-04
344 4.0000e-04
345 5.0000e-04
346 4.0000e-04
347 3.0000e-04
348 2.0000e-04
349 1.0000e-04
350 1.0000e-04
351 1.0000e-04
352 1.0000e-04
353 3.0000e-04
354 6.0000e-04
355 1.6000e-03
356 2.1500e-02
357 9.4100e-02
358 1.6010e-01
359 1.8190e-01
360 1.5650e-01
361 3.0620e-01
362 6.3700e-02
363 1.7300e-02
364 9.3000e-03
365 6.4000e-03
366 5.7000e-03
367 3.6000e-03
368 1.8000e-03
369 1.9000e-03
370 3.1000e-03
371 4.4000e-03
372 3.1000e-03
373 2.4000e-03
374 1.4000e-03
375 1.9000e-03
376 3.0000e-03
377 2.4000e-03
378 2.3000e-03
379 2.3000e-03
380 2.4000e-03
381 3.8000e-03
382 5.9000e-03
383 4.4000e-03
384 2.7000e-03
385 9.0000e-04
386 3.0000e-04
387 2.0000e-04
388 4.0000e-04
389 5.0000e-04
390 5.0000e-04
391 5.0000e-04
392 5.0000e-04
393 6.0000e-04
394 9.0000e-04
395 1.4000e-03
396 2.6000e-03
397 2.9000e-03
398 1.5000e-03
399 5.0000e-04
400 2.0000e-04
401 2.0000e-04
402 4.0000e-04
403 4.0000e-04
404 4.0000e-04
405 5.0000e-04
406 3.0000e-04
407 2.0000e-04
408 2.0000e-04
409 2.0000e-04
410 2.0000e-04
411 3.0000e-04
412 1.0000e-04
413 0.0000e+00
414 1.0000e-04
415 3.0000e-04
416 5.0000e-04
417 7.0000e-04
418 3.7000e-03
419 5.6300e-02
420 2.0470e-01
421 2.8580e-01
422 3.3910e-01
423 1.7000e-02
424 7.5000e-03
425 5.7000e-03
426 3.0000e-03
427 3.1000e-03
428 3.1000e-03
429 2.3000e-03
430 2.4000e-03
431 3.3000e-03
432 5.9000e-03
433 5.4000e-03
434 3.8000e-03
435 3.1000e-03
436 2.9000e-03
437 3.1000e-03
438 2.3000e-03
439 1.6000e-03
440 9.0000e-04
441 1.1000e-03
442 3.4000e-03
443 4.0000e-03
444 3.0000e-03
445 1.4000e-03
446 3.0000e-04
447 1.0000e-04
448 1.0000e-04
449 1.0000e-04
450 2.0000e-04
451 3.0000e-04
452 4.0000e-04
453 6.0000e-04
454 1.2000e-03
455 1.4000e-03
456 2.1000e-03
457 3.0000e-03
458 2.8000e-03
459 1.3000e-03
460 4.0000e-04
461 2.0000e-04
462 2.0000e-04
463 4.0000e-04
464 4.0000e-04
465 4.0000e-04
466 4.0000e-04
467 3.0000e-04
468 2.0000e-04
469 2.0000e-04
470 1.0000e-04
471 0.0000e+00
472 1.0000e-04
473 1.0000e-04
474 1.0000e-04
475 1.0000e-04
476 2.0000e-04
477 2.0000e-04
478 6.0000e-04
479 9.7000e-03
480 1.3370e-01
481 3.3580e-01
482 4.3060e-01
483 8.6630e-01
484 2.3900e-02
485 8.1000e-03
486 5.7000e-03
487 3.6000e-03
488 2.2000e-03
489 3.4000e-03
490 3.5000e-03
491 3.4000e-03
492 3.3000e-03
493 5.4000e-03
494 6.3000e-03
495 4.3000e-03
496 2.6000e-03
497 1.1000e-03
498 8.0000e-04
499 8.0000e-04
500 6.0000e-04
501 4.0000e-04
502 7.0000e-04
503 2.3000e-03
504 2.5000e-03
505 1.9000e-03
506 7.0000e-04
507 2.0000e-04
508 1.0000e-04
509 1.0000e-04
510 1.0000e-04
511 3.0000e-04
512 3.0000e-04
513 4.0000e-04
514 1.4000e-03
515 2.0000e-03
516 1.5000e-03
517 1.8000e-03
518 1.7000e-03
519 1.6000e-03
520 1.1000e-03
521 3.0000e-04
522 1.0000e-04
523 2.0000e-04
524 3.0000e-04
525 2.0000e-04
526 1.0000e-04
527 1.0000e-04
528 1.0000e-04
529 2.0000e-04
530 1.0000e-04
531 0.0000e+00
532 5.3949e-06
533 0.0000e+00
534 1.0000e-04
535 1.0000e-04
536 1.0000e-04
537 3.0000e-04
538 5.0000e-04
539 1.2000e-03
540 1.7000e-02
541 1.6890e-01
542 4.5900e-01
543 1.0767e+00
544 1.5200e-02
545 8.9000e-03
546 4.8000e-03
547 4.5000e-03
548 3.1000e-03
549 2.9000e-03
550 2.6000e-03
551 2.4000e-03
552 1.7000e-03
553 2.4000e-03
554 4.0000e-03
555 4.4000e-03
556 2.7000e-03
557 8.0000e-04
558 4.0000e-04
559 8.0000e-04
560 1.1000e-03
561 9.0000e-04
562 9.0000e-04
563 1.7000e-03
564 1.4000e-03
565 6.0000e-04
566 3.0000e-04
567 2.0000e-04
568 1.0000e-04
569 1.0000e-04
570 3.0000e-04
571 4.0000e-04
572 2.0000e-04
573 4.0000e-04
574 1.5000e-03
575 1.8000e-03
576 1.1000e-03
577 1.0000e-03
578 1.0000e-03
579 1.4000e-03
580 1.2000e-03
581 5.0000e-04
582 2.0000e-04
583 3.0000e-04
584 3.0000e-04
585 1.0000e-04
586 1.0000e-04
587 1.0000e-04
588 2.0000e-04
589 4.0000e-04
590 2.0000e-04
591 1.0000e-04
592 8.1061e-06
593 0.0000e+00
594 1.0000e-04
595 2.0000e-04
596 2.0000e-04
597 3.0000e-04
598 8.0000e-04
599 3.3000e-03
600 4.1600e-02
601 2.4900e-01
602 8.1980e-01
603 1.2581e+00
604 2.7200e-02
605 1.0500e-02
606 4.7000e-03
607 5.1000e-03
608 4.7000e-03
609 3.8000e-03
610 3.1000e-03
611 1.9000e-03
612 2.1000e-03
613 4.9000e-03
614 6.2000e-03
615 4.9000e-03
616 2.7000e-03
617 1.5000e-03
618 1.0000e-03
619 8.0000e-04
620 8.0000e-04
621 1.2000e-03
622 2.0000e-03
623 1.8000e-03
624 8.0000e-04
625 2.0000e-04
626 1.0000e-04
627 1.0000e-04
628 1.0000e-04
629 1.0000e-04
630 3.0000e-04
631 2.0000e-04
632 1.0000e-04
633 3.0000e-04
634 7.0000e-04
635 1.0000e-03
636 7.0000e-04
637 7.0000e-04
638 1.0000e-03
639 1.1000e-03
640 1.2000e-03
641 7.0000e-04
642 5.0000e-04
643 7.0000e-04
644 9.0000e-04
645 3.0000e-04
646 2.0000e-04
647 2.0000e-04
648 2.0000e-04
649 5.0000e-04
650 4.0000e-04
651 1.0000e-04
652 1.0000e-04
653 1.0000e-04
654 1.0000e-04
655 2.0000e-04
656 2.0000e-04
657 3.0000e-04
658 1.0000e-03
659 7.1000e-03
660 1.1590e-01
661 5.3240e-01
662 1.3092e+00
663 9.9000e-03
664 5.8000e-03
665 5.4000e-03
666 5.4000e-03
667 5.6000e-03
668 8.3000e-03
669 9.6000e-03
670 8.1000e-03
671 8.7000e-03
672 8.7000e-03
673 6.0000e-03
674 2.8000e-03
675 1.8000e-03
676 1.6000e-03
677 1.1000e-03
678 1.2000e-03
679 1.6000e-03
680 1.8000e-03
681 1.0000e-03
682 4.0000e-04
683 2.0000e-04
684 1.0000e-04
685 1.0000e-04
686 1.0000e-04
687 1.0000e-04
688 3.0000e-04
689 4.0000e-04
690 3.0000e-04
691 5.0000e-04
692 6.0000e-04
693 7.0000e-04
694 3.0000e-04
695 5.0000e-04
696 7.0000e-04
697 6.0000e-04
698 5.0000e-04
699 6.0000e-04
700 7.0000e-04
701 9.0000e-04
702 2.1000e-03
703 1.3000e-03
704 6.0000e-04
705 5.0000e-04
706 5.0000e-04
707 8.0000e-04
708 5.0000e-04
709 1.0000e-04
710 2.0000e-04
711 3.0000e-04
712 5.0000e-04
713 1.7000e-03
714 1.9000e-03
715 1.5000e-03
716 1.9000e-03
717 1.5000e-02
718 1.8060e-01
719 5.4960e-01
720 2.0700e-02
721 5.3000e-03
722 7.0000e-03
723 6.7000e-03
724 5.9000e-03
725 6.8000e-03
726 9.5000e-03
727 8.9000e-03
728 7.4000e-03
729 5.8000e-03
730 4.6000e-03
731 3.4000e-03
732 2.7000e-03
733 3.0000e-03
734 2.1000e-03
735 2.5000e-03
736 2.5000e-03
737 2.2000e-03
738 9.0000e-04
739 4.0000e-04
740 2.0000e-04
741 0.0000e+00
742 0.0000e+00
743 1.0000e-04
744 1.0000e-04
745 3.0000e-04
746 7.0000e-04
747 9.0000e-04
748 8.0000e-04
749 9.0000e-04
750 1.0000e-03
751 7.0000e-04
752 6.0000e-04
753 5.0000e-04
754 5.0000e-04
755 4.0000e-04
756 7.0000e-04
757 9.0000e-04
758 8.0000e-04
759 1.5000e-03
760 1.6000e-03
761 1.0000e-03
762 1.0000e-03
763 2.1000e-03
764 2.9000e-03
765 1.2000e-03
766 5.0000e-04
767 8.0000e-04
768 1.0000e-03
769 7.0000e-04
770 1.5000e-03
771 3.2000e-03
772 3.7000e-03
773 2.7000e-03
774 1.6500e-02
775 4.1700e-02
776 1.3100e-02
777 9.6000e-03
778 8.3000e-03
779 8.0000e-03
780 6.8000e-03
781 9.3000e-03
782 1.1800e-02
783 9.8000e-03
784 8.0000e-03
785 7.7000e-03
786 6.2000e-03
787 4.3000e-03
788 3.8000e-03
789 3.8000e-03
790 3.2000e-03
791 3.9000e-03
792 2.9000e-03
793 7.0000e-04
794 4.0000e-04
795 4.0000e-04
796 1.0000e-04
797 0.0000e+00
798 1.0000e-04
799 4.0000e-04
800 5.0000e-04
801 5.0000e-04
802 7.0000e-04
803 1.1000e-03
804 1.4000e-03
805 1.8000e-03
806 1.5000e-03
807 8.0000e-04
808 6.0000e-04
809 7.0000e-04
810 1.1000e-03
811 1.2000e-03
812 8.0000e-04
813 7.0000e-04
814 1.3000e-03
815 1.5000e-03
816 1.2000e-03
817 1.4000e-03
818 1.9000e-03
819 2.1000e-03
820 9.0000e-04
821 1.1000e-03
822 1.7000e-03
823 1.4000e-03
824 3.3600e-02
825 2.6500e-02
826 1.7900e-02
827 1.6200e-02
828 1.6700e-02
829 1.6400e-02
830 1.6200e-02
831 1.4700e-02
832 1.1100e-02
833 8.7000e-03
834 7.8000e-03
835 8.7000e-03
836 9.1000e-03
837 8.1000e-03
838 7.9000e-03
839 6.4000e-03
840 7.0000e-03
841 6.2000e-03
842 3.5000e-03
843 1.7000e-03
844 1.4000e-03
845 9.0000e-04
846 5.0000e-04
847 8.0000e-04
848 1.2000e-03
849 1.2000e-03
850 1.0000e-03
851 1.2000e-03
852 1.8000e-03
853 2.7000e-03
854 2.7000e-03
855 2.0000e-03
856 1.6000e-03
857 1.1000e-03
858 1.0000e-03
859 2.2000e-03
860 1.9000e-03
861 8.0000e-04
862 1.1000e-03
863 2.6000e-03
864 2.0000e-03
865 1.1000e-03
866 1.5000e-03
867 1.2000e-03
868 8.8500e-02
869 4.6700e-02
870 2.2400e-02
871 2.0800e-02
872 1.8600e-02
873 2.2100e-02
874 2.2100e-02
875 1.8300e-02
876 1.8600e-02
877 1.8800e-02
878 1.7900e-02
879 1.6200e-02
880 1.1100e-02
881 8.6000e-03
882 1.2500e-02
883 1.6300e-02
884 1.3200e-02
885 5.4000e-03
886 2.5000e-03
887 2.2000e-03
888 1.7000e-03
889 1.1000e-03
890 1.9000e-03
891 7.3700e-02
892 1.9200e-02
893 1.4500e-02
894 1.1300e-02
895 1.6200e-02
896 1.7000e-02
897 1.3300e-02
898 1.3400e-02
899 7.5000e-03
900 7.2000e-03
901 1.3400e-02
902 1.9700e-02
903 1.1200e-02
904 7.6000e-03
905 1.6300e-02
906 2.1600e-02
907 1.2200e-02
908 4.2000e-03
909 2.4000e-03
910 2.4000e-03
911 8.6100e-02
912 1.8300e-02
913 9.6000e-03
914 2.5000e-03
915 1.8000e-03
916 2.0000e-03
917 3.0000e-04
918 1.0000e-04
919 3.0000e-04
920 1.3000e-03
921 2.4000e-03
922 1.1000e-03
923 1.0000e-04
924 8.0000e-04
925 7.6000e-03
926 1.2000e-02
927 1.1000e-02
928 4.0600e-02
929 1.6300e-02
930 1.4800e-02
931 6.7000e-03
932 4.0000e-04
933 2.0000e-04
934 3.0000e-03
935 9.7000e-03
936 1.8900e-02
937 5.9800e-02
938 9.7000e-02
939 1.1930e-01
940 3.1500e-02
941 1.0500e-02
942 1.9000e-03
943 3.0000e-04
Node.js
In this example we will test the EvapotraspirationTemporalVariationJson which allow the user to get a json with the temporal variation of the vegetation index.
To use the following example you have to replace:
- USEREMAIL
- APIKEY
- fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
- action, the action must be setted as none, new, edit. If you want to receive the data based on the polygons saved in the past set none. If you want to add a new field set as new. If you want to change the shape of the polygons set edit.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
With your information and let’s try out the API.
// Load Libraries
const fs = require('fs');
const axios = require('axios');
// set the username and apikey
const useremail = 'XXXXXXXXXXXX';
const apikey = 'XXXXXXXXXXXX';
// Set API Parameters
const fieldnumber="1";
const action="none";
// set the api url
const apiUrl = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationTemporalVariationJsonNew?';
// Set api endpoint
const apiendpoint = apiUrl.concat("fieldnumber=", fieldnumber, "&action=", action);
const file_path_to_geojson = './county.geojson';
async function main() {
try {
const geojson = JSON.parse(fs.readFileSync(file_path_to_geojson, 'utf8'));
const authHeader = `Basic ${Buffer.from(`${useremail}:${apikey}`).toString('base64')}`;
const response = await axios.post(apiendpoint, geojson, {
headers: {
Authorization: authHeader,
'Content-Type': 'application/json',
,
};
})
// Print the formatted JSON response to the console
console.log(JSON.stringify(response.data, null, 2));
catch (error) {
} console.error('An error occurred:', error.message);
}
}
main();
Java
Work in progress
Easy - Fast - Customizable