# Import libraries
import requests
import webbrowser
import json
# Set the vegetation index
="1"
fieldnumber="new"
action="ndvi"
vegetationindex="EsriWorldImagery"
initialmap="onelastmonth"
filterTime="one"
basemap
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/VegetationIndexHtmlWidgetNew?fieldnumber="
API_endpoint
# Set the api call
= API_endpoint+fieldnumber+"&action="+action+"&vegetationindex="+vegetationindex+"&initialmap="+initialmap+"&filterTime="+filterTime+"&basemap="+basemap
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
HTML widgets
In this section we will focus on the html widgets.
The html widgets available are:
- Leaflet Map
- Echarts for graphs
The Leaflet Map html widget is composed by:
- Leaflet map that the end-user can interact with it
- Colored vegetation indexes, prescription maps, zone management
- Legend
The endpoints that allow you to get the html widgets are:
“AFS/VegetationIndexHtmlWidget” endpoint, which allow you to get a leaflet html widget with the vegetation indexes available for you
“AFS/EchartsVegetationIndexTemporalVariation” endpoint, which allow you to get a echart html widget with the temporal variation of the vegetation index or the vegetation index data frequency
“AFS/EvapotraspirationMapHtmlWidget” endpoint, which allow you to get a leaflet html widget with the evapotraspiration map available for you
“/AFS/EvapotraspirationHtmlWidgetEcharts” endpoint, which allow you to get a echart html widget with the temporal variation of the evapotraspiration map or the evapotraspiration data frequency
/AFS/ForecastVineyardMapHtmlWidget endpoint, which allow you to get a leaflet html widget with the forecast yield vineyard map available for you
/AFS/ForecastVineyardEchartsHtmlWidget endpoint, which allow you to get a echart html widget with the temporal variation of the forecast yield vineyard mapp or the forecast yield vineyard data frequency
“AFS/ZoneManagementHtmlWidget” endpoint, which allow you to get a leaflet html widget with the zone management map available for you
“AFS/AutoPrescriptionHtmlWidget” endpoint, which allow you to get a leaflet html widget with the prescription manp available for you.
“AFS/SoilOrganicCarbonMultiYearDataHtmlMap” This endpoint allow you to get a a html leaflet colored map where within map there are the multiyear soil organic maps.
“AFS/SoilOrganicCarbonMultiYearDataHtmlEcharts”, This endpoint allow you to get a a html echart graphs where you will find the temporal variations of the soil organic carbon during years.
“AFS/SoilMoistureHtmlMap” This endpoint allow you to get a a html leaflet colored map where within map there is the soil moisture maps.
“AFS/SoilMoistureHtmlEcharts” This endpoint allow you to get a a html echart graphs where you will find the temporal variations of the soil moisture.
“AFS/DEMhtmlwidget” This endpoint allow you to get a a html leaflet map where you will find the digital elevation model (DEM).
Before to continue we would like to explain to you the difference between the Zone management and Prescription Map
The zone management and prescription map are quite different:
- Zone Managament is the map where you differentiate the different zones of the field, but those zones do not have any dose or agronomic input set, so when you receive this file you should then associate to cada zone a dose
- Prescription Map is the map where for each set zone the dose value and agronomic input is then associated, and then this map is ready to be used directly by tractors.
VegetationIndexHtmlWidget
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- Vegetation index that you would like to receive. Must be one of ndvi,evi2,msavi2,ipvi,msr,osavi,savi,tdvi,gari,arvi,evi,gci,gndvi,gosavi,grvi,nnir,gsavi,vdvi,wdrvi
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- geojson file (you can find it here county.geojson the county file of the example)
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- Vegetation index that you would like to receive. Must be one of ndvi,evi2,msavi2,ipvi,msr,osavi,savi,tdvi,gari,arvi,evi,gci,gndvi,gosavi,grvi,nnir,gsavi,vdvi,wdrvi
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
Warning: il pacchetto 'httr' è stato creato con R versione 4.2.3
# Set the vegetation index
="1"
fieldnumber="none"
action="ndvi"
vegetationindex="EsriWorldImagery"
initialmap="onelastmonth"
filterTime="one"
basemap
# Set the API endpoint
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/VegetationIndexHtmlWidgetNew?fieldnumber="
api_endpoint
# Set the API call
<-paste0(api_endpoint,fieldnumber,"&action=",action,"&vegetationindex=",vegetationindex,"&initialmap=",initialmap, "&filterTime=", filterTime, "&basemap=", basemap)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USEREMAIL="apikey"
APIKEY
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USEREMAIL),
password = Sys.getenv(APIKEY)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
[1] 200
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"VegetationIndexHtmlWidget_1.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- Vegetation index that you would like to receive. Must be one of ndvi,evi2,msavi2,ipvi,msr,osavi,savi,tdvi,gari,arvi,evi,gci,gndvi,gosavi,grvi,nnir,gsavi,vdvi,wdrvi
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// set the vegetation Vegetation index
const fieldnumber="1";
const action="new";
const vegetationindex="ndvi";
const initialmap="EsriWorldImagery";
const filterTime="onelastmonth";
const basemap="one";
// set api endpoint
const API_endpoint = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/VegetationIndexHtmlWidgetNew?fieldnumber=';
// set the api call
const API_URL=API_endpoint.concat(fieldnumber,"&action=",action, "&vegetationindex=",vegetationindex, "&initialmap=",initialmap, "&filterTime=",filterTime,"&basemap=",basemap)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
EchartsVegetationIndexTemporalVariation
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- Vegetation index that you would like to receive. Must be one of ndvi,evi2,msavi2,ipvi,msr,osavi,savi,tdvi,gari,arvi,evi,gci,gndvi,gosavi,grvi,nnir,gsavi,vdvi,wdrvi
- geojson file (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Set the vegetation index
="1"
fieldnumber="new"
action="ndvi"
vegetationindex
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/EchartsVegetationIndexTemporalVariationNew?fieldnumber="
API_endpoint
# Set the api call
= API_endpoint+fieldnumber+"&action="+action+"&vegetationindex="+vegetationindex
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- Vegetation index that you would like to receive. Must be one of ndvi,evi2,msavi2,ipvi,msr,osavi,savi,tdvi,gari,arvi,evi,gci,gndvi,gosavi,grvi,nnir,gsavi,vdvi,wdrvi
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Set the vegetation index
="1"
fieldnumber="new"
action="ndvi"
vegetationindex
# Set the API endpoint
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/EchartsVegetationIndexTemporalVariationNew?fieldnumber="
api_endpoint
# Set the API call
<-paste0(api_endpoint,fieldnumber,"&action=",action,"&vegetationindex=",vegetationindex)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"VegetationIndexHtmlWidget_2.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- Vegetation index that you would like to receive. Must be one of ndvi,evi2,msavi2,ipvi,msr,osavi,savi,tdvi,gari,arvi,evi,gci,gndvi,gosavi,grvi,nnir,gsavi,vdvi,wdrvi
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// set the vegetation Vegetation index
const fieldnumber="1";
const action="new";
const vegetationindex="ndvi";
// set api endpoint
const API_endpoint = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/EchartsVegetationIndexTemporalVariationNew?fieldnumber=';
// set the api call
const API_URL=API_endpoint.concat(fieldnumber,"&action=",action, "&vegetationindex=",vegetationindex)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
EvapotraspirationMapHtmlWidget
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Set the vegetation index
="1"
fieldnumber="new"
action="EsriWorldImagery"
initialmap="onelastmonth"
filterTime="one"
basemap
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapHtmlWidgetNew?fieldnumber="
API_endpoint
# Set the api call
= API_endpoint+fieldnumber+"&action="+action+"&initialmap="+initialmap+"&filterTime="+filterTime+"&basemap="+basemap
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Set the API parameter
="1"
fieldnumber="new"
action="EsriWorldImagery"
initialmap="onelastmonth"
filterTime="one"
basemap
# Set the API endpoint
<- 'https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapHtmlWidgetNew?fieldnumber='
API_endpoint
# Set the API url
<-paste0(API_endpoint,fieldnumber, "&action=",action, "&initialmap=", initialmap, "&filterTime=",filterTime, "&basemap=",basemap)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"EvapotraspirationMapHtmlWidget_3.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// set API parameters
const fieldnumber="1";
const action="new";
const initialmap="EsriWorldImagery";
const filterTime="onelastmonth";
const basemap="one";
// set api endpoint
const API_endpoint = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapHtmlWidgetNew?fieldnumber=';
// set api url
const API_URL=API_endpoint.concat(API_endpoint,fieldnumber,"&action=",action, "&initialmap=", initialmap, "&filterTime=",filterTime, "&basemap=",basemap)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
EvapotraspirationHtmlWidgetEcharts
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Set API parameter
="1"
fieldnumber="new"
action
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationHtmlWidgetEchartsNew?fieldnumber="
API_URL
=API_URL+fieldnumber+"&action="+action
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Set API Parameter
="1"
fieldnumber="new"
action
# Set the api endpoint
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationHtmlWidgetEchartsNew?fieldnumber="
API_URL
<-paste0(API_URL, fieldnumber, "&action=", action)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"VegetationIndexHtmlWidget_4.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// set API patameter
const fieldnumber="1";
const action="new";
// set api endpoint
const API_URL = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationHtmlWidgetEchartsNew?fieldnumber=';
const API_endpoint = API_URL.concat(fieldnumber, "&action=", action)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_endpoint, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
ForecastVineyardMapHtmlWidget
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Set the API parameter
="1"
fieldnumber="new"
action="EsriWorldImagery"
initialmap="onelastmonth"
filterTime="one"
basemap
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardMapHtmlWidgetNew?fieldnumber="
API_endpoint
=API_endpoint+fieldnumber+"&action="+action+"&initialmap="+initialmap+"&filterTime="+filterTime+"&basemap="+basemap
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Set API parameter
="1"
fieldnumber="new"
action="EsriWorldImagery"
initialmap="onelastmonth"
filterTime="one"
basemap
# Set the API endpoint
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardMapHtmlWidgetNew?fieldnumber="
API_endpoint
# Set the API url
<- paste0(API_endpoint,fieldnumber, "&action=",action, "&initialmap=", initialmap, "&filterTime=",filterTime,"&basemap=",basemap)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"VegetationIndexHtmlWidget_5.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// set API parameter
const fieldnumber="1";
const action="new";
const initialmap="EsriWorldImagery";
const filterTime="onelastmonth";
const basemap="one";
// set API endpoint
const API_endpoint = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardMapHtmlWidgetNew?fieldnumber=';
// Set the API url
const API_URL=API_endpoint.concat(fieldnumber,"&action=",action,"&initialmap=",initialmap, "&filterTime=",filterTime, "&basemap=",basemap)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
ForecastVineyardEchartsHtmlWidget
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# set API parameter
="1"
fieldnumber="new"
action
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardEchartsHtmlWidgetNew?fieldnumber="
API_URL
=API_URL+fieldnumber+"&action="+action
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Set API parameter
="1"
fieldnumber="new"
action
# Set the api endpoint
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardEchartsHtmlWidgetNew?fieldnumber="
API_URL
<-paste0(API_URL,fieldnumber,"&action=",action)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"VegetationIndexHtmlWidget_6.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// Set API parameter
="1"
fieldnumber="new"
action
// set api endpoint
const API_URL = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardEchartsHtmlWidgetNew?fieldnumber=';
const api_endpoint = API_URL.concat(fieldnumber, "&action=", action)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(api_endpoint, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
AutoPrescriptionHtmlWidget
Python
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- Userfertilizer, set the amount of agronomic input to provide on avarage to the field
- Strategy, can be set as highwherehigh or highwherelow. If highwherehigh means provide an higher amout of fertilizer where the vegetation indexes is higher. If highwherelow means provide an higher amout of fertilizer where the vegetation indexes is lower
- ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
- ProductName, Set the name of the product name that you want to provide (e.g. Urea, AmmoniumNitrate, the word don’t have to have space)
- GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- DoseDifference, Set the difference percentange of the dose that you want to apply between the zones. you can set a value between 0 to 100. if you set 0 an automatic process will define the difference of the dose based on vegetation index values.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Define the API call parameters
="1"
fieldnumber="new"
action="False"
AutoPrescription="3"
NumberZone="200"
userfertilizer="highwherehigh"
Strategy="Solid"
ProductType="Urea"
ProductName="WGS84"
GeographicReference="EsriWorldImagery"
initialmap="one"
basemap="0"
DoseDifference
# Define the url of the API
= "https://www.api.automaticfarmsolutionwebapp.com/AFS/AutoPrescriptionHtmlWidgetNew?fieldnumber="+fieldnumber+"&action="+action+"&AutoPrescription="+AutoPrescription+"&NumberZone="+NumberZone+"&userfertilizer="+userfertilizer+"&Strategy="+Strategy+"&ProductType="+ProductType+"&ProductName="+ProductName+"&GeographicReference="+GeographicReference+"&initialmap="+initialmap+"&basemap="+basemap+"&DoseDifference="+DoseDifference
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- Userfertilizer, set the amount of agronomic input to provide on avarage to the field
- Strategy, can be set as highwherehigh or highwherelow. If highwherehigh means provide an higher amout of fertilizer where the vegetation indexes is higher. If highwherelow means provide an higher amout of fertilizer where the vegetation indexes is lower
- ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
- ProductName, Set the name of the product name that you want to provide (e.g. Urea, AmmoniumNitrate, the word don’t have to have space)
- GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Define the API call parameters
="1"
fieldnumber="new"
action="False"
AutoPrescription="3"
NumberZone="200"
userfertilizer="highwherehigh"
Strategy="Solid"
ProductType="Urea"
ProductName="WGS84"
GeographicReference="EsriWorldImagery"
initialmap="one"
basemap="0"
DoseDifference
# Define the url of the API
= paste0("https://www.api.automaticfarmsolutionwebapp.com/AFS/AutoPrescriptionHtmlWidgetNew?fieldnumber=",fieldnumber,"&action=",action, "&AutoPrescription=",AutoPrescription,"&NumberZone=",NumberZone,"&userfertilizer=",userfertilizer,"&Strategy=",Strategy,"&ProductType=",ProductType,"&ProductName=",ProductName,"&GeographicReference=",GeographicReference,"&initialmap=",initialmap,"&basemap=",basemap, "&DoseDifference=", DoseDifference)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"AutoPrescriptionHtmlWidget_7.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- Userfertilizer, set the amount of agronomic input to provide on avarage to the field
- Strategy, can be set as highwherehigh or highwherelow. If highwherehigh means provide an higher amout of fertilizer where the vegetation indexes is higher. If highwherelow means provide an higher amout of fertilizer where the vegetation indexes is lower
- ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
- ProductName, Set the name of the product name that you want to provide (e.g. Urea, AmmoniumNitrate, the word don’t have to have space)
- GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// Set the API Parameter
const fieldnumber="1";
const action="new";
const AutoPrescription = "False";
const NumberZone = "4";
const Userfertilizer="200";
const Strategy = "highwherehigh";
const ProductType = "Solid";
const ProductName = "Urea";
const GeographicReference = "WGS84";
const initialmap="EsriWorldImagery";
const basemap="one";
// Set API Url
const api_url='https://www.api.automaticfarmsolutionwebapp.com/AFS/AutoPrescriptionHtmlWidgetNew?fieldnumber=';
// Set endpoint Url
const API_URL = api_url.concat(fieldnumber,"&action=",action, "&AutoPrescription=", AutoPrescription, "&NumberZone=", NumberZone, "&userfertilizer=", Userfertilizer, "&Strategy=",Strategy,"&ProductType=",ProductType,"&ProductName=",ProductName,"&GeographicReference=",GeographicReference, "&initialmap=", initialmap, "&basemap=",basemap);
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
AutoPrescriptionAIbasedHtmlWidgetNew
Python
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- Userfertilizer, set the amount of agronomic input to provide on avarage to the field
- Strategy, can be set as highwherehigh or highwherelow. If highwherehigh means provide an higher amout of fertilizer where the vegetation indexes is higher. If highwherelow means provide an higher amout of fertilizer where the vegetation indexes is lower
- ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
- ProductName, Set the name of the product name that you want to provide (e.g. Urea, AmmoniumNitrate, the word don’t have to have space)
- GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- DoseDifference, Set the difference percentange of the dose that you want to apply between the zones. you can set a value between 0 to 100. if you set 0 an automatic process will define the difference of the dose based on vegetation index values.
- CropSelected, Set the crop that you want to fertilize (the availablecrops are available at the AvailableCrops API endpoint)
- Nutrient, Set the nutrient that you want to provide (Could be nitrogen, phosphorus, potassium)
- ExpectedYield, Set the expected yield reacheble by the crop quintals per hectare.
- TitleFertilizer, The title of the fertilizer (like 46 for Urea)
- NumberApplicationYear, The number of fertilizer applications during the growing year of the crop
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Define the API call parameters
="1"
fieldnumber="new"
action="False"
AutoPrescription="3"
NumberZone="200"
userfertilizer="highwherehigh"
Strategy="Solid"
ProductType="Urea"
ProductName="WGS84"
GeographicReference="EsriWorldImagery"
initialmap="one"
basemap="0"
DoseDifference="Durum_wheat"
CropSelected="nitrogen"
Nutrient=60
ExpectedYield=46
TitleFertilizer=2
NumberApplicationYear
# Define the url of the API
= "https://www.api.automaticfarmsolutionwebapp.com/AFS/AutoPrescriptionAIbasedHtmlWidgetNew?fieldnumber="+fieldnumber+"&action="+action+"&AutoPrescription="+AutoPrescription+"&NumberZone="+NumberZone+"&userfertilizer="+userfertilizer+"&Strategy="+Strategy+"&ProductType="+ProductType+"&ProductName="+ProductName+"&GeographicReference="+GeographicReference+"&initialmap="+initialmap+"&basemap="+basemap+"&DoseDifference="+DoseDifference+"&CropSelected="+CropSelected+"&Nutrient="+Nutrient+"&ExpectedYield="+ExpectedYield+"&TitleFertilizer="+TitleFertilizer+"&NumberApplicationYear="+NumberApplicationYear
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- Userfertilizer, set the amount of agronomic input to provide on avarage to the field
- Strategy, can be set as highwherehigh or highwherelow. If highwherehigh means provide an higher amout of fertilizer where the vegetation indexes is higher. If highwherelow means provide an higher amout of fertilizer where the vegetation indexes is lower
- ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
- ProductName, Set the name of the product name that you want to provide (e.g. Urea, AmmoniumNitrate, the word don’t have to have space)
- GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- CropSelected, Set the crop that you want to fertilize (the availablecrops are available at the AvailableCrops API endpoint)
- Nutrient, Set the nutrient that you want to provide (Could be nitrogen, phosphorus, potassium)
- ExpectedYield, Set the expected yield reacheble by the crop quintals per hectare.
- TitleFertilizer, The title of the fertilizer (like 46 for Urea)
- NumberApplicationYear, The number of fertilizer applications during the growing year of the crop
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Define the API call parameters
="1"
fieldnumber="none"
action="False"
AutoPrescription="3"
NumberZone="200"
userfertilizer="highwherehigh"
Strategy="Solid"
ProductType="Urea"
ProductName="WGS84"
GeographicReference="EsriWorldImagery"
initialmap="one"
basemap="0"
DoseDifference ="Durum_wheat"
CropSelected="nitrogen"
Nutrient=60
ExpectedYield=46
TitleFertilizer=2
NumberApplicationYear
# Define the url of the API
= paste0("https://www.api.automaticfarmsolutionwebapp.com/AFS/AutoPrescriptionAIbasedHtmlWidgetNew?fieldnumber=",fieldnumber,"&action=",action, "&AutoPrescription=",AutoPrescription,"&NumberZone=",NumberZone,"&userfertilizer=",userfertilizer,"&Strategy=",Strategy,"&ProductType=",ProductType,"&ProductName=",ProductName,"&GeographicReference=",GeographicReference,"&initialmap=",initialmap,"&basemap=",basemap, "&DoseDifference=", DoseDifference,"&CropSelected=",CropSelected,"&Nutrient=",Nutrient,"&ExpectedYield=",ExpectedYield,"&TitleFertilizer=",TitleFertilizer,"&NumberApplicationYear=",NumberApplicationYear)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
[1] 200
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"AutoPrescriptionHtmlWidget_7.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- Userfertilizer, set the amount of agronomic input to provide on avarage to the field
- Strategy, can be set as highwherehigh or highwherelow. If highwherehigh means provide an higher amout of fertilizer where the vegetation indexes is higher. If highwherelow means provide an higher amout of fertilizer where the vegetation indexes is lower
- ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
- ProductName, Set the name of the product name that you want to provide (e.g. Urea, AmmoniumNitrate, the word don’t have to have space)
- GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- CropSelected, Set the crop that you want to fertilize (the availablecrops are available at the AvailableCrops API endpoint)
- Nutrient, Set the nutrient that you want to provide (Could be nitrogen, phosphorus, potassium)
- ExpectedYield, Set the expected yield reacheble by the crop quintals per hectare.
- TitleFertilizer, The title of the fertilizer (like 46 for Urea)
- NumberApplicationYear, The number of fertilizer applications during the growing year of the crop
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// Set the API Parameter
const fieldnumber="1";
const action="new";
const AutoPrescription = "False";
const NumberZone = "4";
const Userfertilizer="200";
const Strategy = "highwherehigh";
const ProductType = "Solid";
const ProductName = "Urea";
const GeographicReference = "WGS84";
const initialmap="EsriWorldImagery";
const basemap="one";
const DoseDifference ="0";
const CropSelected="Durum_wheat";
const Nutrient="nitrogen";
const ExpectedYield=60;
const TitleFertilizer=46;
const NumberApplicationYear=2;
// Set API Url
const api_url='https://www.api.automaticfarmsolutionwebapp.com/AFS/AutoPrescriptionAIbasedHtmlWidgetNew?fieldnumber=';
// Set endpoint Url
const API_URL = api_url.concat(fieldnumber,"&action=",action, "&AutoPrescription=", AutoPrescription, "&NumberZone=", NumberZone, "&userfertilizer=", Userfertilizer, "&Strategy=",Strategy,"&ProductType=",ProductType,"&ProductName=",ProductName,"&GeographicReference=",GeographicReference, "&initialmap=", initialmap, "&basemap=",basemap,"&DoseDifference=",DoseDifference,"&CropSelected=",CropSelected,"&Nutrient=",Nutrient,"&ExpectedYield=",ExpectedYield,"&TitleFertilizer=",TitleFertilizer,"&NumberApplicationYear=",NumberApplicationYear);
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
ZoneManagementHtmlWidget
Python
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Define the API call parameters
="1"
fieldnumber="new"
action="False"
AutoPrescription="3"
NumberZone="EsriWorldImagery"
initialmap="one"
basemap
# Define the url of the API
= "https://www.api.automaticfarmsolutionwebapp.com/AFS/ZoneManagementHtmlWidgetNew?fieldnumber="+fieldnumber+"&action="+action+"&AutoPrescription="+AutoPrescription+"&NumberZone="+NumberZone+"&initialmap="+initialmap+"&basemap="+basemap
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Define the API call parameters
="1"
fieldnumber="new"
action="False"
AutoPrescription="3"
NumberZone="EsriWorldImagery"
initialmap="one"
basemap
# Define the url of the API
<- paste0("https://www.api.automaticfarmsolutionwebapp.com/AFS/ZoneManagementHtmlWidgetNew?fieldnumber=",fieldnumber,"&action=",action,"&AutoPrescription=",AutoPrescription,"&NumberZone=",NumberZone, "&initialmap=",initialmap,"&basemap=",basemap)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"ZoneManagementHtmlWidget_8.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- 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.
- AutoPrescription, Must be set as True or False. If True means that number and position of zone management are setted automatically; If False means that number of zone management are setted by the user by definig the NumberZone parameter
- NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- file_path_to_geojson (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// Set the API Parameter
const fieldnumber="1";
const action="new";
const AutoPrescription = "False";
const NumberZone = "4";
const initialmap="EsriWorldImagery";
const basemap="one";
// Set API Url
const api_url='https://www.api.automaticfarmsolutionwebapp.com/AFS/ZoneManagementHtmlWidgetNew?fieldnumber=';
// Set endpoint Url
const API_URL = api_url.concat(fieldnumber,"&action=",action,"&AutoPrescription=", AutoPrescription, "&NumberZone=", NumberZone, "&initialmap=", initialmap, "&basemap=",basemap);
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
SoilMoistureHtmlMap
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Set API parameters
="1"
fieldnumber="new"
action="EsriWorldImagery"
initialmap="onelastmonth"
filterTime="one"
basemap
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlMapNew?fieldnumber="
API_endpoint
# Set API Call
=API_endpoint+fieldnumber+"&action="+action+"&initialmap=" +initialmap+"&filterTime="+filterTime+"&basemap="+basemap
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Set the API parameters
="1"
fieldnumber="new"
action="EsriWorldImagery"
initialmap="onelastmonth"
filterTime="one"
basemap
# Set the API endpoint
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlMapNew?fieldnumber="
API_endpoint
# Set API call
<-paste0(API_endpoint, fieldnumber,"&action=",action,"&initialmap=", initialmap, "&filterTime=",filterTime, "&basemap=",basemap)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"VegetationIndexHtmlWidget_11.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- filterTime, Set the date filter can be onelastmonth, twolastmonth or none
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// Set the API parameters
const fieldnumber="1";
const action="new";
const initialmap="EsriWorldImagery";
const filterTime="onelastmonth";
const basemap ="one";
// set API endpoint
const API_endpoint = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlMapNew?fieldnumber=';
// set the API call
const API_URL=API_endpoint.concat(fieldnumber,"&action=",action,"&initialmap=",initialmap, "&filterTime=", filterTime, "&basemap=",basemap)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
SoilMoistureHtmlEcharts
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Set API parameter
="1"
fieldnumber="new"
action
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlEchartsNew?fieldnumber="
API_URL
=API_URL+fieldnumber+"&action="+action
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Set API parameter
="1"
fieldnumber="new"
action
# Set the api endpoint
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlEchartsNew?fieldnumber="
API_URL
<-paste0(API_URL, fieldnumber, "&action=", action)
API_URL
# Set the path to geojson
<- "Campo_1.geojson"
geojson
# Set username and password
="useremail"
USERNAME="apikey"
PASSWORD
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USERNAME),
password = Sys.getenv(PASSWORD)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"VegetationIndexHtmlWidget_12.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// Set API parameter
const fieldnumber="1";
const action="new";
// set API endpoint
const API_endpoint = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlEchartsNew?fieldnumber=';
// Set API url
const API_URL = API_endpoint.concat(fieldnumber, "&action=", action)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
DEMhtmlwidget
Python
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- geojson file (you can find it here county.geojson the county file of the example)
# Import libraries
import requests
import webbrowser
import json
# Set the API parameters
="EsriWorldImagery"
initialmap="one"
basemap
# Set the API endpoint
="https://www.api.automaticfarmsolutionwebapp.com/AFS/DEMhtmlwidget?"
API_URL
=API_URL+"&initialmap="+initialmap+"&basemap="+basemap
API_URL
# Set the path to the geojson
= "county.geojson"
geojson
# Set username & password
="XXXXXX"
USERNAME="XXXXXX"
PASSWORD
# Set the authentication header
= {
auth_data "username": USERNAME,
"password": PASSWORD
}
# Read the content of geojson
with open(geojson, "r") as file:
= json.load(file)
geojson_data
# Make the POST request
= requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))
response
# Check the status of the response
if response.status_code == 200:
# Save the content of the response to an HTML file
with open("Response.html", "wb") as file:
file.write(response.content)
# Open the HTML file in your default browser
open("Response.html")
webbrowser.else:
print(f"The request was unsuccessful. Status code: {response.status_code}")
R
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- geojson file (you can find it here county.geojson the county file of the example)
# Load libraries
library(httr)
# Set API parameters
="EsriWorldImagery"
initialmap="one"
basemap
# Set the API endpoint
<- "https://www.api.automaticfarmsolutionwebapp.com/AFS/DEMhtmlwidget?"
API_URL
<-paste0(API_URL, "&initialmap=", initialmap, "&basemap=", basemap)
API_URL
# Set the path to geojson
<- "county.geojson"
geojson
# Set username and password
="useremail"
USEREMAIL="apikey"
APIKEY
# Make the post request
<- POST(
response
API_URL,authenticate(
user = Sys.getenv(USEREMAIL),
password = Sys.getenv(APIKEY)
),body=upload_file(geojson)
)
# Get the status code of the response
status_code(response)
# Parse the response content
<- content(response, as = "text")
response_content
# Write and show html file
writeLines(response_content,"DEMHtmlWidget_1.html")
Node.js
In order to use this endpoint you have to set up the following parameter
- USERNAME
- PASSWORD
- 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.
- initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
- basemap, Parameter that allows you to determine whether to receive every base map or receive only the base map selected with the initialmap parameter. Must be setted as one for just the selected basemap, or all to get all the base maps.
- geojson file (you can find it here county.geojson the county file of the example)
// load libraries
const express = require('express');
const axios = require('axios');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// set the API Parameters
const initialmap= "EsriWorldImagery";
const basemap= "one";
// set api endpoint
const API_URL = 'https://www.api.automaticfarmsolutionwebapp.com/AFS/DEMhtmlwidget?initialmap=';
const API_URL_def=API_URL.concat(initialmap,"&basemap=",basemap)
// set username and password
const USERNAME = 'XXXXXXXXXXXX';
const PASSWORD = 'XXXXXXXXXXXX';
.get('/', async (req, res) => {
apptry {
// Read the GeoJSON file
const geojson = fs.readFileSync("county.geojson", 'utf8');
// Set up the authentication headers
const authHeaders = {
auth: {
username: USERNAME,
password: PASSWORD,
,
};
}
// Perform the authenticated POST request
const response = await axios.post(API_URL_def, geojson, authHeaders);
// Assuming the response data contains the HTML content
const htmlContent = response.data;
// Send the HTML content as the response
.send(htmlContent);
rescatch (error) {
} console.error('Error:', error);
.status(500).send('An error occurred');
res
};
})
.listen(PORT, () => {
appconsole.log(`Server is running on port ${PORT}`);
; })
Easy - Fast - Customizable