HTML widgets

In this section we will focus on the html widgets.

The html widgets available are:

  1. Leaflet Map
  2. Echarts for graphs

The Leaflet Map html widget is composed by:

  1. Leaflet map that the end-user can interact with it
  2. Colored vegetation indexes, prescription maps, zone management
  3. Legend

The endpoints that allow you to get the html widgets are:

  1. “AFS/VegetationIndexHtmlWidget” endpoint, which allow you to get a leaflet html widget with the vegetation indexes available for you

  2. “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

  3. “AFS/EvapotraspirationMapHtmlWidget” endpoint, which allow you to get a leaflet html widget with the evapotraspiration map available for you

  4. “/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

  5. /AFS/ForecastVineyardMapHtmlWidget endpoint, which allow you to get a leaflet html widget with the forecast yield vineyard map available for you

  6. /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

  7. “AFS/ZoneManagementHtmlWidget” endpoint, which allow you to get a leaflet html widget with the zone management map available for you

  8. “AFS/AutoPrescriptionHtmlWidget” endpoint, which allow you to get a leaflet html widget with the prescription manp available for you.

  9. “AFS/SoilOrganicCarbonMultiYearDataHtmlMap” This endpoint allow you to get a a html leaflet colored map where within map there are the multiyear soil organic maps.

  10. “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.

  11. “AFS/SoilMoistureHtmlMap” This endpoint allow you to get a a html leaflet colored map where within map there is the soil moisture maps.

  12. “AFS/SoilMoistureHtmlEcharts” This endpoint allow you to get a a html echart graphs where you will find the temporal variations of the soil moisture.

  13. “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

Zone Management vs Prescription Map

The zone management and prescription map are quite different:

  1. 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
  2. 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. 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.
  9. 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

fieldnumber="1"
action="new"
vegetationindex="ndvi"
initialmap="EsriWorldImagery"
filterTime="onelastmonth"
basemap="one"

# Set the API endpoint

API_endpoint="https://www.api.automaticfarmsolutionwebapp.com/AFS/VegetationIndexHtmlWidgetNew?fieldnumber="

# Set the api call

API_URL = API_endpoint+fieldnumber+"&action="+action+"&vegetationindex="+vegetationindex+"&initialmap="+initialmap+"&filterTime="+filterTime+"&basemap="+basemap

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. 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.
  9. 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

fieldnumber="1"
action="none"
vegetationindex="ndvi"
initialmap="EsriWorldImagery"
filterTime="onelastmonth"
basemap="one"

# Set the API endpoint

api_endpoint <- "https://www.api.automaticfarmsolutionwebapp.com/AFS/VegetationIndexHtmlWidgetNew?fieldnumber=" 

# Set the API call

API_URL<-paste0(api_endpoint,fieldnumber,"&action=",action,"&vegetationindex=",vegetationindex,"&initialmap=",initialmap, "&filterTime=", filterTime, "&basemap=", basemap)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USEREMAIL="useremail"
APIKEY="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  7. 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.
  8. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  9. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

EchartsVegetationIndexTemporalVariation

Python

In order to use this endpoint you have to set up the following parameter

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. 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

fieldnumber="1"
action="new"
vegetationindex="ndvi"

# Set the API endpoint

API_endpoint="https://www.api.automaticfarmsolutionwebapp.com/AFS/EchartsVegetationIndexTemporalVariationNew?fieldnumber="

# Set the api call

API_URL = API_endpoint+fieldnumber+"&action="+action+"&vegetationindex="+vegetationindex

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. geojson file (you can find it here county.geojson the county file of the example)
# Load libraries 
library(httr)

# Set the vegetation index

fieldnumber="1"
action="new"
vegetationindex="ndvi"

# Set the API endpoint

api_endpoint <- "https://www.api.automaticfarmsolutionwebapp.com/AFS/EchartsVegetationIndexTemporalVariationNew?fieldnumber=" 

# Set the API call

API_URL<-paste0(api_endpoint,fieldnumber,"&action=",action,"&vegetationindex=",vegetationindex)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

EvapotraspirationMapHtmlWidget

Python

In order to use this endpoint you have to set up the following parameter

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. 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

fieldnumber="1"
action="new"
initialmap="EsriWorldImagery"
filterTime="onelastmonth"
basemap="one"

# Set the API endpoint

API_endpoint="https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapHtmlWidgetNew?fieldnumber="

# Set the api call

API_URL = API_endpoint+fieldnumber+"&action="+action+"&initialmap="+initialmap+"&filterTime="+filterTime+"&basemap="+basemap

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. geojson file (you can find it here county.geojson the county file of the example)
# Load libraries 
library(httr)

# Set the API parameter

fieldnumber="1"
action="new"
initialmap="EsriWorldImagery"
filterTime="onelastmonth"
basemap="one"

# Set the API endpoint
API_endpoint <- 'https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationMapHtmlWidgetNew?fieldnumber='

# Set the API url
API_URL<-paste0(API_endpoint,fieldnumber, "&action=",action, "&initialmap=", initialmap, "&filterTime=",filterTime, "&basemap=",basemap)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

EvapotraspirationHtmlWidgetEcharts

Python

In order to use this endpoint you have to set up the following parameter

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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

fieldnumber="1"
action="new"

# Set the API endpoint

API_URL="https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationHtmlWidgetEchartsNew?fieldnumber="

API_URL=API_URL+fieldnumber+"&action="+action

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. geojson file (you can find it here county.geojson the county file of the example)
# Load libraries 
library(httr)

# Set API Parameter

fieldnumber="1"
action="new"

# Set the api endpoint

API_URL <- "https://www.api.automaticfarmsolutionwebapp.com/AFS/EvapotraspirationHtmlWidgetEchartsNew?fieldnumber="

API_URL<-paste0(API_URL, fieldnumber, "&action=", action)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

ForecastVineyardMapHtmlWidget

Python

In order to use this endpoint you have to set up the following parameter

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. 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

fieldnumber="1"
action="new"
initialmap="EsriWorldImagery"
filterTime="onelastmonth"
basemap="one"

# Set the API endpoint

API_endpoint="https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardMapHtmlWidgetNew?fieldnumber="

API_URL=API_endpoint+fieldnumber+"&action="+action+"&initialmap="+initialmap+"&filterTime="+filterTime+"&basemap="+basemap

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. geojson file (you can find it here county.geojson the county file of the example)
# Load libraries 

library(httr)

# Set API parameter

fieldnumber="1"
action="new"
initialmap="EsriWorldImagery"
filterTime="onelastmonth"
basemap="one"

# Set the API endpoint

API_endpoint <- "https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardMapHtmlWidgetNew?fieldnumber="

# Set the API url 

API_URL <- paste0(API_endpoint,fieldnumber, "&action=",action, "&initialmap=",  initialmap, "&filterTime=",filterTime,"&basemap=",basemap)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

ForecastVineyardEchartsHtmlWidget

Python

In order to use this endpoint you have to set up the following parameter

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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

fieldnumber="1"
action="new"

# Set the API endpoint

API_URL="https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardEchartsHtmlWidgetNew?fieldnumber="

API_URL=API_URL+fieldnumber+"&action="+action

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. geojson file (you can find it here county.geojson the county file of the example)
# Load libraries 

library(httr)

# Set API parameter

fieldnumber="1"
action="new"

# Set the api endpoint

API_URL <- "https://www.api.automaticfarmsolutionwebapp.com/AFS/ForecastVineyardEchartsHtmlWidgetNew?fieldnumber=" 

API_URL<-paste0(API_URL,fieldnumber,"&action=",action)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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

fieldnumber="1"
action="new"

// 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

AutoPrescriptionHtmlWidget

Python

In order to use this endpoint you have to set up the following parameter

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. Userfertilizer, set the amount of agronomic input to provide on avarage to the field
  8. 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
  9. ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
  10. 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)
  11. GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
  12. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  13. 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.
  14. 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.
  15. 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

fieldnumber="1"
action="new"
AutoPrescription="False"
NumberZone="3"
userfertilizer="200"
Strategy="highwherehigh"
ProductType="Solid"
ProductName="Urea"
GeographicReference="WGS84"
initialmap="EsriWorldImagery"
basemap="one"
DoseDifference="0"

# Define the url of the API

API_URL = "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

# Set the path to the geojson

geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. Userfertilizer, set the amount of agronomic input to provide on avarage to the field
  8. 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
  9. ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
  10. 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)
  11. GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
  12. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  13. 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.
  14. 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

fieldnumber="1"
action="new"
AutoPrescription="False"
NumberZone="3"
userfertilizer="200"
Strategy="highwherehigh"
ProductType="Solid"
ProductName="Urea"
GeographicReference="WGS84"
initialmap="EsriWorldImagery"
basemap="one"
DoseDifference ="0"

# Define the url of the API

API_URL = 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)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. Userfertilizer, set the amount of agronomic input to provide on avarage to the field
  8. 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
  9. ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
  10. 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)
  11. GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
  12. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  13. 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.
  14. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

AutoPrescriptionAIbasedHtmlWidgetNew

Python

In order to use this endpoint you have to set up the following parameter

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. Userfertilizer, set the amount of agronomic input to provide on avarage to the field
  8. 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
  9. ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
  10. 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)
  11. GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
  12. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  13. 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.
  14. 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.
  15. CropSelected, Set the crop that you want to fertilize (the availablecrops are available at the AvailableCrops API endpoint)
  16. Nutrient, Set the nutrient that you want to provide (Could be nitrogen, phosphorus, potassium)
  17. ExpectedYield, Set the expected yield reacheble by the crop quintals per hectare.
  18. TitleFertilizer, The title of the fertilizer (like 46 for Urea)
  19. NumberApplicationYear, The number of fertilizer applications during the growing year of the crop
  20. 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

fieldnumber="1"
action="new"
AutoPrescription="False"
NumberZone="3"
userfertilizer="200"
Strategy="highwherehigh"
ProductType="Solid"
ProductName="Urea"
GeographicReference="WGS84"
initialmap="EsriWorldImagery"
basemap="one"
DoseDifference="0"
CropSelected="Durum_wheat"
Nutrient="nitrogen"
ExpectedYield=60
TitleFertilizer=46
NumberApplicationYear=2

# Define the url of the API

API_URL = "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

# Set the path to the geojson

geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. Userfertilizer, set the amount of agronomic input to provide on avarage to the field
  8. 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
  9. ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
  10. 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)
  11. GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
  12. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  13. 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.
  14. CropSelected, Set the crop that you want to fertilize (the availablecrops are available at the AvailableCrops API endpoint)
  15. Nutrient, Set the nutrient that you want to provide (Could be nitrogen, phosphorus, potassium)
  16. ExpectedYield, Set the expected yield reacheble by the crop quintals per hectare.
  17. TitleFertilizer, The title of the fertilizer (like 46 for Urea)
  18. NumberApplicationYear, The number of fertilizer applications during the growing year of the crop
  19. 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

fieldnumber="1"
action="none"
AutoPrescription="False"
NumberZone="3"
userfertilizer="200"
Strategy="highwherehigh"
ProductType="Solid"
ProductName="Urea"
GeographicReference="WGS84"
initialmap="EsriWorldImagery"
basemap="one"
DoseDifference ="0"
CropSelected="Durum_wheat"
Nutrient="nitrogen"
ExpectedYield=60
TitleFertilizer=46
NumberApplicationYear=2

# Define the url of the API

API_URL = 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)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. Userfertilizer, set the amount of agronomic input to provide on avarage to the field
  8. 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
  9. ProductType, Set the type of the product type that you want to provide (e.g. Solid, Fluid, Liquid)
  10. 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)
  11. GeographicReference, Must be WGS84 or report the number of the UTM zone (e.g. 33, 32, 22)
  12. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  13. 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.
  14. CropSelected, Set the crop that you want to fertilize (the availablecrops are available at the AvailableCrops API endpoint)
  15. Nutrient, Set the nutrient that you want to provide (Could be nitrogen, phosphorus, potassium)
  16. ExpectedYield, Set the expected yield reacheble by the crop quintals per hectare.
  17. TitleFertilizer, The title of the fertilizer (like 46 for Urea)
  18. NumberApplicationYear, The number of fertilizer applications during the growing year of the crop
  19. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

ZoneManagementHtmlWidget

Python

In order to use this endpoint you have to set up the following parameter

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  8. 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.
  9. 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

fieldnumber="1"
action="new"
AutoPrescription="False"
NumberZone="3"
initialmap="EsriWorldImagery"
basemap="one"

# Define the url of the API

API_URL = "https://www.api.automaticfarmsolutionwebapp.com/AFS/ZoneManagementHtmlWidgetNew?fieldnumber="+fieldnumber+"&action="+action+"&AutoPrescription="+AutoPrescription+"&NumberZone="+NumberZone+"&initialmap="+initialmap+"&basemap="+basemap

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  8. 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.
  9. 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

fieldnumber="1"
action="new"
AutoPrescription="False"
NumberZone="3"
initialmap="EsriWorldImagery"
basemap="one"

# Define the url of the API

API_URL <- paste0("https://www.api.automaticfarmsolutionwebapp.com/AFS/ZoneManagementHtmlWidgetNew?fieldnumber=",fieldnumber,"&action=",action,"&AutoPrescription=",AutoPrescription,"&NumberZone=",NumberZone, "&initialmap=",initialmap,"&basemap=",basemap)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USEREMAIL
  2. APIKEY
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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
  6. NumberZone, if AutoPrescription is setted False, here you can specify the number of zone
  7. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  8. 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.
  9. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

SoilMoistureHtmlMap

Python

In order to use this endpoint you have to set up the following parameter

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. 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

fieldnumber="1"
action="new"
initialmap="EsriWorldImagery"
filterTime="onelastmonth"
basemap="one"

# Set the API endpoint

API_endpoint="https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlMapNew?fieldnumber="

# Set API Call
API_URL=API_endpoint+fieldnumber+"&action="+action+"&initialmap=" +initialmap+"&filterTime="+filterTime+"&basemap="+basemap

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. geojson file (you can find it here county.geojson the county file of the example)
# Load libraries 

library(httr)

# Set the API parameters

fieldnumber="1"
action="new"
initialmap="EsriWorldImagery"
filterTime="onelastmonth"
basemap="one"

# Set the API endpoint

API_endpoint <- "https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlMapNew?fieldnumber="

# Set API call
API_URL<-paste0(API_endpoint, fieldnumber,"&action=",action,"&initialmap=", initialmap, "&filterTime=",filterTime, "&basemap=",basemap)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. filterTime, Set the date filter can be onelastmonth, twolastmonth or none
  8. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

SoilMoistureHtmlEcharts

Python

In order to use this endpoint you have to set up the following parameter

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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

fieldnumber="1"
action="new"

# Set the API endpoint

API_URL="https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlEchartsNew?fieldnumber="

API_URL=API_URL+fieldnumber+"&action="+action

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. geojson file (you can find it here county.geojson the county file of the example)
# Load libraries 
library(httr)

# Set API parameter

fieldnumber="1"
action="new"

# Set the api endpoint

API_URL <- "https://www.api.automaticfarmsolutionwebapp.com/AFS/SoilMoistureHtmlEchartsNew?fieldnumber=" 

API_URL<-paste0(API_URL, fieldnumber, "&action=", action)

# Set the path to geojson

geojson <- "Campo_1.geojson"

# Set username and password

USERNAME="useremail"
PASSWORD="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

DEMhtmlwidget

Python

In order to use this endpoint you have to set up the following parameter

  1. USERNAME
  2. PASSWORD
  3. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  4. 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.
  5. 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

initialmap="EsriWorldImagery"
basemap="one"

# Set the API endpoint

API_URL="https://www.api.automaticfarmsolutionwebapp.com/AFS/DEMhtmlwidget?"

API_URL=API_URL+"&initialmap="+initialmap+"&basemap="+basemap

# Set the path to the geojson
geojson = "county.geojson"

# Set username & password

USERNAME="XXXXXX"
PASSWORD="XXXXXX"

# Set the authentication header
auth_data = {
    "username": USERNAME,
    "password": PASSWORD
}

# Read the content of geojson
with open(geojson, "r") as file:
    geojson_data = json.load(file)

# Make the POST request
response = requests.post(API_URL, json=geojson_data, auth=(auth_data["username"], auth_data["password"]))

# 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
    webbrowser.open("Response.html")
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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. geojson file (you can find it here county.geojson the county file of the example)
# Load libraries 

library(httr)

# Set API parameters

initialmap="EsriWorldImagery"
basemap="one"

# Set the API endpoint

API_URL <- "https://www.api.automaticfarmsolutionwebapp.com/AFS/DEMhtmlwidget?" 

API_URL<-paste0(API_URL, "&initialmap=", initialmap, "&basemap=", basemap)

# Set the path to geojson

geojson <- "county.geojson"

# Set username and password

USEREMAIL="useremail"
APIKEY="apikey"

# Make the post request

response <- POST(
  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
response_content <- content(response, as = "text")

# 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

  1. USERNAME
  2. PASSWORD
  3. fieldnumber, The field number. You have to refereed to the field that you can get from the gid column of the UserField endpoint response
  4. 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.
  5. initialmap, The name of the base map you wuould like to display disrt (could be one of CartNormal, CartoDark, EsriWorldImagery, OpenTopoMap)
  6. 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.
  7. 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';

app.get('/', async (req, res) => {
  try {
    // 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
    res.send(htmlContent);
  } catch (error) {
    console.error('Error:', error);
    res.status(500).send('An error occurred');
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

Easy - Fast - Customizable

Back to top