×

OpenWeather
Meteorological Service

Dan Hart Speak to the Chief
Meteorologist Dan Hart and
his team!

Dive into the Agro API | Part 2 – Polygons

Dive into the Agro API | Part 2 – Polygons

Posted on 06 Aug 2018

By: Maxim Samokhin
Backend Developer, OpenWeather

This article is a step-by-step description of how to work with polygons using our QueryBuilder and Agro API instruments. Part 1 explained how to use your personal OpenWeather account – be sure to set it up before starting to read this article.

To work with the Agro API, you need to create polygons (in GeoJSON format) with your fields or areas of interest. We will discuss the methods of working with polygons, such as deleting, receiving and updating them, below. You can refer to our documentation for more details. To make it easy to work with our documentation, please follow the steps below:

1) To create your polygon, you can use our QueryBuilder tile service (see Image 1)

Or, if you have already created the polygons you need, go to step 3.

Image 1. Query Builder

2) Now you need to find the area of your interest on the map. Click on the polygon drawing button (Image 2).

Image 2. Query Builder Toolbar

3) Select the relevant area on the map (Image 3).

Image 3. Query Builder Toolbar

4) By clicking on the “VIEW POLYGON GEOJSON” button (Image 2), you will receive a prepared polygon in the GeoJSON format in a pop-up window (Image 4).

Image 4. Query Builder: GeoJSON preview

For all of the following steps, you need to use HTTP request methods.

5) Append the polygon you have created in step 4 to the Agro API service.

You need to create a POST request like this:

http://api.agromonitoring.com/agro/1.0/polygons?appid={appid}

  Parameter

  Description

  appid

 Your API Key from your personal account  


The body of the POST request must contain a JSON-format structure in the following form:

Image 5. POST request in JSON format

In the response, you will get a JSON-format structure in the following form:

Image 6. Response in JSON format


6) Get information about a polygon.

You need to create a GET request like this:

http://api.agromonitoring.com/agro/1.0/polygons/{polygon_id}?appid={appid}

   Parameter

  Description

  appid

  Your API Key from your personal account 

  polygon_id

  The “id” parameter that is contained in the response from step 5


In response, you will get a JSON-format structure in the following form:

Image 7. Response in JSON format

7) Get information about all your polygons.

You need to create a GET request like this: 

http://api.agromonitoring.com/agro/1.0/polygons?appid={appid}

  Parameter

  Description

  appid

 Your API Key from your personal account


In response, you will get a JSON-format structure in the following form with a list of all your polygons:

Image 8. Response in JSON format

8) Update information about a polygon.

You need to create a PUT request like this:

http://api.agromonitoring.com/agro/1.0/polygons/{polygon_id}?appid={appid}

  Parameter

  Description

  appid

Your API Key from your personal account  

  polygon_id

 The “id” parameter that is contained in the responses from steps 5 and 7


The body of the PUT request must contain a JSON-format structure in the following form:

Image 9. PUT request in JSON format

Please note: You can only update the “name” field in your polygon information. Other fields from your PUT request will be ignored.

In response, you will get a JSON-format structure in the following form, with your newly updated parameters:

Image 10. Response in JSON format

9) Remove a polygon.

Then you need to make a GET request like this:

http://api.agromonitoring.com/agro/1.0/polygons/{polygon_id}?appid={appid}

  Parameter

  Description

  appid

  Your API Key from your personal account 

  polygon_id

   The “id” parameter that is contained in the response from steps 5 and 7


To find out more detailed information about Agro API service requests (response codes, API request error descriptions and so on), please refer to our documentation.

Dive into Agro API | Part 1 - Personal Account
Dive into Agro API | Part 3 - Historical NDVI
Dive into Agro API | Part 4 – Satellite Imagery

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.