CropAI - BETA

This API is in BETA. Please contact us to demo this API, or for more information on production scale models.

Crop Identification

Service Overview

The Ag-Analytics® Crop Identification API timely and accurately determines the spatial distribution, area, and type of crops present on a given field. This beta version uses machine learning models to provide a back-filling crop identification service meaning that it is used for the past years in the field where all the relevant information exists, but the crop type is uncertain.


Crop Identification API in use on FarmScope® via CropAI tool.


Model Specifications

The Crop Identification Model, of which the Crop Identification API is based on, takes four main factors into consideration: Location, Weather, Soil information, and Remote Sensing Satellite Imagery/Data. Location, weather, and soil are the three most determining factors in if a given crop will be planted and thrive in a certain area. Remote Sensing Satellite imagery/Data provides near real-time information of a given crop at different developing stages during its growing season.

Sample API Specifications

Please contact us to demo our crop identification models. See sample API call below.

Request Parameters


Parameter Data Type Required Default Options Description
SHAPE Geometry, file/text Yes - GeoJSON (file/text),
JSON Geometry objects (file/text)
Desired area of interest.
CropSeason Text Yes - 2013-2019 The year of interest to retrieve the crop type information.
Ex. "2018"
ModelType Text String No* "NN" "NN"
(Neural Network)

"TREE"
Decision Tree
The type of AI Model to be used.
*If "NN" or "TREE" are not input, must pass as an empty string.


Request Example - application/json


application/json
{"SHAPE": "{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100.953840994,38.5946753571],[-100.953832008,38.5948720599],[-100.953876941,38.5952162884],[-100.953957821,38.5955324152],[-100.953984781,38.5955745654],[-100.954029714,38.5957361407],[-100.954245394,38.5961716896],[-100.954452087,38.5964807873],[-100.95473966,38.5968179832],[-100.954910406,38.596965506],[-100.954910406,38.5969795557],[-100.954982299,38.5970287299],[-100.954982299,38.5970427797],[-100.955359739,38.5973378239],[-100.955377712,38.5973378239],[-100.955629338,38.5975134449],[-100.956042724,38.5977312143],[-100.956357257,38.5978646856],[-100.956707736,38.5979911318],[-100.957175042,38.598110553],[-100.957615388,38.5981878255],[-100.958055734,38.598229974],[-100.958514053,38.5982369988],[-100.958963386,38.5982088998],[-100.959412719,38.5981456769],[-100.959906984,38.5980332805],[-100.96023949,38.5979279087],[-100.960598957,38.5977874128],[-100.960976396,38.5976047676],[-100.961281942,38.597422122],[-100.961560528,38.5972113765],[-100.961578502,38.5972113765],[-100.961848101,38.5969865806],[-100.961982901,38.5968390579],[-100.962018848,38.5968179832],[-100.962189594,38.5966283107],[-100.962315407,38.5964526876],[-100.962405274,38.5964526876],[-100.962405274,38.5963894631],[-100.962369327,38.5963894631],[-100.962369327,38.5963754133],[-100.962513113,38.5961716896],[-100.96262994,38.5959539155],[-100.962800686,38.5955324152],[-100.962908526,38.595054712],[-100.962926499,38.5948580097],[-100.962890553,38.5948509846],[-100.962962446,38.5948650348],[-100.963025352,38.5947947839],[-100.962998393,38.5947877588],[-100.962989406,38.5947666835],[-100.962917513,38.5947526333],[-100.962935486,38.5947245329],[-100.962926499,38.5946894073],[-100.962881566,38.5947034575],[-100.962665886,38.5946823822],[-100.958541013,38.5946753571],[-100.9584152,38.5947175077],[-100.958316347,38.5947175077],[-100.958298374,38.5947034575],[-100.958154587,38.5946753571],[-100.953840994,38.5946753571]]]}}",
    "ScalarVariables": {
        "CropSeason": "2018"
    },
    "ModelType":"NN"
}

Response Parameters


Parameter Type Description
feature_averages List
Averages of the
bi-week remote sensing data and monthly weather data of the area-of-interest:
I. Greenweek#: Green band value on the # week of the year
II. Blueweek#: Blue band value on the # week of the year
III. Redweek#: Red band value on the # week of the year
IV. NIRweek#: Near Infrared band value on the # week of the year
V. SWIR1week#: Shortwave Infrared band 1 value on the # week of the year
VI. SWIR2week#: Shortwave Infrared band 2 value on the # week of the year
VII. GDD#: Monthly growing degree days
VIII. Precipitation#: Monthly precipitation
raster_filename -
URL to download result raster (.tif) file.
rasterinfo.CellSize Resolution
Resolution of result Geotiff file in meters.
rasterinfo.CoordinateSystem -
Information about the projection of the raster.
rasterinfo.Extent -
Extents of the result raster. Specifies the bottom left and top right corners of the field
raster in degrees.
rasterinfo.Legend List
Legend gives
the following details for each range of values:
I. Area: Area covered
II. AreaUnit: Unit of Area covered
III. AreaPercent: Area covered in percentage.
IV. Count: # of pixels from the result raster in that range
V. CountAllPixels: Total # of pixels in the result raster
VI. CropID: Code for the crop identified by model. See Figure 4
VII. CropName: Crop name identified by the model
VIII. Color: Hex color used for the crop type
rasterinfo.pngb64 Link
Base64png image of the result raster with legend entries.


Response Example - application/json


{
  "feature_averages": {
    "Blueweek18": 779.824844896861,
    "Blueweek20": 1975.2838106368124,
    "Blueweek22": 733.3521051359988,
    "Blueweek24": 643.9180616872748,
    "Blueweek26": 344.2115098055459,
    "Blueweek28": 235.72472900506003,
    "Blueweek30": 204.4056550889475,
    "Blueweek32": 216.0730864324732,
    "Blueweek34": 266.59034645931484,
    "Blueweek36": 622.0089586686997,
    "GDD3": 40.4415,
    "GDD4": 88.57439999999998,
    "GDD5": 567.5903999999999,
    "GDD6": 808.3584,
    "GDD7": 216.13589999999996,
    "GDD8": 0.0,
    "Greenweek18": 1138.131570659558,
    "Greenweek20": 2254.270159289066,
    "Greenweek22": 1013.7187401697631,
    "Greenweek24": 928.849268847287,
    "Greenweek26": 571.9230231878212,
    "Greenweek28": 457.9029104885397,
    "Greenweek30": 384.65050915319665,
    "Greenweek32": 375.24875445591255,
    "Greenweek34": 540.8961853834992,
    "Greenweek36": 749.1952922510966,
    "NIRweek18": 2970.0740078383446,
    "NIRweek20": 3536.6660938053815,
    "NIRweek22": 2412.510195847856,
    "NIRweek24": 3292.298120071036,
    "NIRweek26": 3535.8988991057713,
    "NIRweek28": 3721.192446778267,
    "NIRweek30": 3591.1494805204393,
    "NIRweek32": 3262.5500419977257,
    "NIRweek34": 3012.6094064752187,
    "NIRweek36": 2956.2582454919366,
    "Precipitation3": 11.524,
    "Precipitation4": 25.41900000000001,
    "Precipitation5": 70.78399999999999,
    "Precipitation6": 152.91100000000003,
    "Precipitation7": 1.4809999999999999,
    "Precipitation8": 0.0,
    "Redweek18": 1903.1859603449168,
    "Redweek20": 2480.602444221482,
    "Redweek22": 1324.5397082727213,
    "Redweek24": 1069.7853810301349,
    "Redweek26": 512.0971963633662,
    "Redweek28": 379.9113349957818,
    "Redweek30": 283.1936926800272,
    "Redweek32": 279.2847222138893,
    "Redweek34": 467.8558782624387,
    "Redweek36": 727.4151962193739,
    "SWIR1week18": 3338.836322033022,
    "SWIR1week20": 3808.579113377245,
    "SWIR1week22": 3199.2655615880494,
    "SWIR1week24": 1902.9297659572896,
    "SWIR1week26": 1254.004163243775,
    "SWIR1week28": 677.788417488776,
    "SWIR1week30": 962.4707162781339,
    "SWIR1week32": 994.7986702873936,
    "SWIR1week34": 865.6824701031575,
    "SWIR1week36": 628.7585803430337,
    "SWIR2week18": 2391.667558326072,
    "SWIR2week20": 2977.71718115419,
    "SWIR2week22": 2392.3059762302105,
    "SWIR2week24": 1066.0881596873523,
    "SWIR2week26": 577.5711350554554,
    "SWIR2week28": 14.881174763569534,
    "SWIR2week30": 305.1543742073506,
    "SWIR2week32": 299.5264928749243,
    "SWIR2week34": 805.5621165630723,
    "SWIR2week36": 193.83389703934495
  },
  "raster_filename": "result_cropidraster_20191126_183736_2356.tif",
  "rasterinfo": {
    "CellSize": [
      0.0001,
      -0.0001
    ],
    "CoordinateSystem": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]]",
    "Extent": "-100.963025352, 38.5946369988, -100.953925352, 38.5982369988",
    "Legend": [
      {
        "Area": 4.969644751890395, 
        "AreaPercent": '3.82 %',
        "AreaUnit": "ac",
        "Count": 101,
        "CountAllPixels": 2645,
        "CropID": 1,
        "CropName": "CORN_WET",
        "color": "#e8aba4"
      },
      {
        "Area": "96.18 %",
        "Area": 125.17600246345707,
        "AreaPercent": "96.18 %",
        "AreaUnit": "ac",
        "Count": 2544,
        "CountAllPixels": 2645,
        "CropID": 4,
        "CropName": "WHEAT_HRD_RD_SPR",
        "color": "#9d250e"
      }
    ],
    "pngb64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAFsAAAAkCAYAAADmQkaNAAABCklEQVR4nO3Xuw3CMBSFYdsD0DECkzEXXbqMxAKR0jEBFSgY27l+3OM8zt9GSpSPI0dYs6Eet8uscd/783XVuG9utufDtXAl9fgB4Ng9gWOh4CHYWwSOpQmvir0nZD8NdBXsPSP7tURvin0kZL8W6E2wj4zsV4Puah9+Jmhj6t63eNlnQ/YrWXgR9tmhl+WgZx8jhP4txyMLm9DhpC5ibEKnk/iIsAkta81pFZvQeaW8ktiELivmFsUmdF0hv+p/kExeEJurbpPv+IdNaL14jCi3HK+LXWDt47IBfUZMbGBfbB4huk3jMHPZwIgNzBnDIwQVlw2M2MCIDYzYwBw/jri4bGB2GgcuG9Qbz/tZxU5PLj0AAAAASUVORK5CYII="
  }
}

Shape Example - GeoJSON


"{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100.953840994,38.5946753571],[-100.953832008,38.5948720599],[-100.953876941,38.5952162884],[-100.953957821,38.5955324152],[-100.953984781,38.5955745654],[-100.954029714,38.5957361407],[-100.954245394,38.5961716896],[-100.954452087,38.5964807873],[-100.95473966,38.5968179832],[-100.954910406,38.596965506],[-100.954910406,38.5969795557],[-100.954982299,38.5970287299],[-100.954982299,38.5970427797],[-100.955359739,38.5973378239],[-100.955377712,38.5973378239],[-100.955629338,38.5975134449],[-100.956042724,38.5977312143],[-100.956357257,38.5978646856],[-100.956707736,38.5979911318],[-100.957175042,38.598110553],[-100.957615388,38.5981878255],[-100.958055734,38.598229974],[-100.958514053,38.5982369988],[-100.958963386,38.5982088998],[-100.959412719,38.5981456769],[-100.959906984,38.5980332805],[-100.96023949,38.5979279087],[-100.960598957,38.5977874128],[-100.960976396,38.5976047676],[-100.961281942,38.597422122],[-100.961560528,38.5972113765],[-100.961578502,38.5972113765],[-100.961848101,38.5969865806],[-100.961982901,38.5968390579],[-100.962018848,38.5968179832],[-100.962189594,38.5966283107],[-100.962315407,38.5964526876],[-100.962405274,38.5964526876],[-100.962405274,38.5963894631],[-100.962369327,38.5963894631],[-100.962369327,38.5963754133],[-100.962513113,38.5961716896],[-100.96262994,38.5959539155],[-100.962800686,38.5955324152],[-100.962908526,38.595054712],[-100.962926499,38.5948580097],[-100.962890553,38.5948509846],[-100.962962446,38.5948650348],[-100.963025352,38.5947947839],[-100.962998393,38.5947877588],[-100.962989406,38.5947666835],[-100.962917513,38.5947526333],[-100.962935486,38.5947245329],[-100.962926499,38.5946894073],[-100.962881566,38.5947034575],[-100.962665886,38.5946823822],[-100.958541013,38.5946753571],[-100.9584152,38.5947175077],[-100.958316347,38.5947175077],[-100.958298374,38.5947034575],[-100.958154587,38.5946753571],[-100.953840994,38.5946753571]]]}}"






Call API

Request

Request URL

Request headers

  • (optional)
    string

Request body

{
  "SHAPE": "{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100.953840994,38.5946753571],[-100.953832008,38.5948720599],[-100.953876941,38.5952162884],[-100.953957821,38.5955324152],[-100.953984781,38.5955745654],[-100.954029714,38.5957361407],[-100.954245394,38.5961716896],[-100.954452087,38.5964807873],[-100.95473966,38.5968179832],[-100.954910406,38.596965506],[-100.954910406,38.5969795557],[-100.954982299,38.5970287299],[-100.954982299,38.5970427797],[-100.955359739,38.5973378239],[-100.955377712,38.5973378239],[-100.955629338,38.5975134449],[-100.956042724,38.5977312143],[-100.956357257,38.5978646856],[-100.956707736,38.5979911318],[-100.957175042,38.598110553],[-100.957615388,38.5981878255],[-100.958055734,38.598229974],[-100.958514053,38.5982369988],[-100.958963386,38.5982088998],[-100.959412719,38.5981456769],[-100.959906984,38.5980332805],[-100.96023949,38.5979279087],[-100.960598957,38.5977874128],[-100.960976396,38.5976047676],[-100.961281942,38.597422122],[-100.961560528,38.5972113765],[-100.961578502,38.5972113765],[-100.961848101,38.5969865806],[-100.961982901,38.5968390579],[-100.962018848,38.5968179832],[-100.962189594,38.5966283107],[-100.962315407,38.5964526876],[-100.962405274,38.5964526876],[-100.962405274,38.5963894631],[-100.962369327,38.5963894631],[-100.962369327,38.5963754133],[-100.962513113,38.5961716896],[-100.96262994,38.5959539155],[-100.962800686,38.5955324152],[-100.962908526,38.595054712],[-100.962926499,38.5948580097],[-100.962890553,38.5948509846],[-100.962962446,38.5948650348],[-100.963025352,38.5947947839],[-100.962998393,38.5947877588],[-100.962989406,38.5947666835],[-100.962917513,38.5947526333],[-100.962935486,38.5947245329],[-100.962926499,38.5946894073],[-100.962881566,38.5947034575],[-100.962665886,38.5946823822],[-100.958541013,38.5946753571],[-100.9584152,38.5947175077],[-100.958316347,38.5947175077],[-100.958298374,38.5947034575],[-100.958154587,38.5946753571],[-100.953840994,38.5946753571]]]}}",
  "ScalarVariables": {
    "CropSeason": "2018"
  },
  "ModelType": "NN"
}

Code samples

@ECHO OFF

curl -v -X POST "https://ag-analytics.azure-api.net/cropidentification/"
-H "Content-Type: application/json"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers

            var uri = "https://ag-analytics.azure-api.net/cropidentification/?" + queryString;

            HttpResponseMessage response;

            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");

            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }

        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://ag-analytics.azure-api.net/cropidentification/");


            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/json");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://ag-analytics.azure-api.net/cropidentification/?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/json");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://ag-analytics.azure-api.net/cropidentification/";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://ag-analytics.azure-api.net/cropidentification/');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_POST);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('ag-analytics.azure-api.net')
    conn.request("POST", "/cropidentification/?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('ag-analytics.azure-api.net')
    conn.request("POST", "/cropidentification/?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://ag-analytics.azure-api.net/cropidentification/')


request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body