Cropland Data Layers
Crop Land Data Layers, also known as CDLs, are published by USDA and provide estimates of historical crops cover.
Get Request Crop Data Layers
Please note, this API has been deprecated. Please use the new version.
Powered by CROPAI™
The Cropland Data Layer (CDL), produced by the USDA, provides a raster, geo-referenced, crop-specific land cover map for the continental United States. The CDL also includes a crop mask layer and planting frequency layers, as well as boundary, water and road layers. The Boundary Layer options provided are County, Agricultural Statistics Districts (ASD), State, and Region. The data is created annually using moderate resolution satellite imagery and extensive agricultural ground truth.
The purpose of the Cropland Data Layer Program is to use satellite imagery to (1) provide planted acreage estimates to the Agricultural Statistics Board for each state's major commodities and (2) produce digital, crop-specific, categorized geo-referenced output products (Information from here).
Cropland Data Layers in Ag-Analytics FarmScope.
Click the Jupyter Notebook Static Sample to view a static rendition of this APIs Jupyter Notebook.
Click the Jupyter Notebook Github Repo to access the Jupyter Notebook .ipynb files and
instructions needed in order to run this APIs Jupyter Notebook.
Request Parameters
Parameter | Data Type | Required? | Description |
---|---|---|---|
year | integer | Yes | Year of desired result |
inputShape | Esri Polygon Shape | Yes | The shape information for field in esriGeometryPolygon format. Standard open source JavaScript front-end libraries (e.g., Leaflet) can be used to structure the shape. |
env:outSR | String | Yes | Output Spatial Reference. Return features in the specified spatial reference by supplying specific wkid (eg. 4326). |
Response Parameters
Parameter | Data Type | Description |
---|---|---|
results | List | The GP Result resource represents a result parameter for a GP Job. It provides information about the result parameter such as its name, data type and value. |
fields | List | In ArcGIS, rows are known as records and columns are referred to as fields. Each field in a table can store a specific type of data, such as a number, date, or piece of text. Fields form the attribute info for a layer. |
fields.GRIDCODE | Integer | Each GRIDCODE corresponds to a specific crop. |
features | List | An array of features. Each feature contains fields. |
features.geometry | Points, lines or polygons | The structure for the geometries is same as the structure of the JSON geometry objects returned by the ArcGIS REST API. |
features.attributes | List | Key-value pairs where the key is a field name in the list of fields of the record set and the value is the value of the corresponding field. |
GridCode / CropName Table
GridCode | CropName | GridCode | CropName | GridCode | CropName |
---|---|---|---|---|---|
1 |
Corn |
55 |
Caneberries |
207 |
Asparagus |
2 |
Cotton |
56 |
Hops |
208 |
Garlic |
3 |
Rice |
57 |
Herbs |
209 |
Cantaloupes |
4 |
Sorghum |
58 |
Clover/Wildflowers |
210 |
Prunes |
5 |
Soybeans |
59 |
Sod/GrassSeed |
211 |
Olives |
6 |
Sunflower |
60 |
Switchgrass |
212 |
Oranges |
10 |
Peanuts |
61 |
Fallow/IdleCropland |
213 |
HoneydewMelons |
11 |
Tobacco |
63 |
Forest |
214 |
Broccoli |
12 |
SweetCorn |
64 |
Shrubland |
216 |
Peppers |
13 |
PoporOrnCorn |
65 |
Barren |
217 |
Pomegranates |
14 |
Mint |
66 |
Cherries |
218 |
Nectarines |
21 |
Barley |
67 |
Peaches |
219 |
Greens |
22 |
DurumWheat |
68 |
Apples |
220 |
Plums |
23 |
SpringWheat |
69 |
Grapes |
221 |
Strawberries |
24 |
WinterWheat |
70 |
ChristmasTrees |
222 |
Squash |
25 |
OtherSmallGrains |
71 |
OtherTreeCrops |
223 |
Apricots |
26 |
DblCropWinWht/Soybeans |
72 |
Citrus |
224 |
Vetch |
27 |
Rye |
74 |
Pecans |
225 |
DblCropWinWht/Corn |
28 |
Oats |
75 |
Almonds |
226 |
DblCropOats/Corn |
29 |
Millet |
76 |
Walnuts |
227 |
Lettuce |
30 |
Speltz |
77 |
Pears |
229 |
Pumpkins |
31 |
Canola |
81 |
Clouds/NoData |
230 |
DblCropLettuce/DurumWht |
32 |
Flaxseed |
82 |
Developed |
231 |
DblCropLettuce/Cantaloupe |
33 |
Safflower |
83 |
Water |
232 |
DblCropLettuce/Cotton |
34 |
RapeSeed |
87 |
Wetlands |
233 |
DblCropLettuce/Barley |
35 |
Mustard |
88 |
Nonag/Undefined |
234 |
DblCropDurumWht/Sorghum |
36 |
Alfalfa |
92 |
Aquaculture |
235 |
DblCropBarley/Sorghum |
37 |
OtherHay/NonAlfalfa |
111 |
OpenWater |
236 |
DblCropWinWht/Sorghum |
38 |
Camelina |
112 |
PerennialIce/Snow |
237 |
DblCropBarley/Corn |
39 |
Buckwheat |
121 |
Developed/OpenSpace |
238 |
DblCropWinWht/Cotton |
41 |
Sugarbeets |
122 |
Developed/LowIntensity |
239 |
DblCropSoybeans/Cotton |
42 |
DryBeans |
123 |
Developed/MedIntensity |
240 |
DblCropSoybeans/Oats |
43 |
Potatoes |
124 |
Developed/HighIntensity |
241 |
DblCropCorn/Soybeans |
44 |
OtherCrops |
131 |
Barren |
242 |
Blueberries |
45 |
Sugarcane |
141 |
DeciduousForest |
243 |
Cabbage |
46 |
SweetPotatoes |
142 |
EvergreenForest |
244 |
Cauliflower |
47 |
MiscVegs&Fruits |
143 |
MixedForest |
245 |
Celery |
48 |
Watermelons |
152 |
Shrubland |
246 |
Radishes |
49 |
Onions |
176 |
Grassland/Pasture |
247 |
Turnips |
50 |
Cucumbers |
190 |
WoodyWetlands |
248 |
Eggplants |
51 |
ChickPeas |
195 |
HerbaceousWetlands |
249 |
Gourds |
52 |
Lentils |
204 |
Pistachios |
250 |
Cranberries |
53 |
Peas |
205 |
Triticale |
254 |
DblCropBarley/Soybeans |
54 |
Tomatoes |
206 |
Carrots |
|
|
Call API
Request
Request URL
Request parameters
-
Year of desired result.
-
(ESRI Polygon shape): The shape information for field in esriGeometryPolygon format. Standard open source JavaScript front-end libraries (e.g., Leaflet) can be used to structure the shape
-
(optional)
Output Spatial Reference. Return features in the specified spatial reference by supplying specific wkid (eg. 4326).
Request headers
-
string
Request body
Responses
200 OK
Code samples
@ECHO OFF
curl -v -X GET "https://ag-analytics.azure-api.net/CroplandDataLayers/get?year={year}&inputShape={inputShape}?env:outSR=4326"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--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
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
// Request parameters
queryString["env:outSR"] = "4326";
var uri = "https://ag-analytics.azure-api.net/CroplandDataLayers/get?year={year}&inputShape={inputShape}&" + queryString;
var response = await client.GetAsync(uri);
}
}
}
// // 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/CroplandDataLayers/get?year={year}&inputShape={inputShape}");
builder.setParameter("env:outSR", "4326");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
// 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
"env:outSR": "4326",
};
$.ajax({
url: "https://ag-analytics.azure-api.net/CroplandDataLayers/get?year={year}&inputShape={inputShape}&" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "GET",
// 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/CroplandDataLayers/get?year={year}&inputShape={inputShape}";
NSArray* array = @[
// Request parameters
@"entities=true",
@"env:outSR=4326",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
// Request headers
[_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
// 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/CroplandDataLayers/get?year={year}&inputShape={inputShape}');
$url = $request->getUrl();
$headers = array(
// Request headers
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'env:outSR' => '4326',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// 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
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
# Request parameters
'env:outSR': '4326',
})
try:
conn = httplib.HTTPSConnection('ag-analytics.azure-api.net')
conn.request("GET", "/CroplandDataLayers/get?year={year}&inputShape={inputShape}&%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
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
# Request parameters
'env:outSR': '4326',
})
try:
conn = http.client.HTTPSConnection('ag-analytics.azure-api.net')
conn.request("GET", "/CroplandDataLayers/get?year={year}&inputShape={inputShape}&%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/CroplandDataLayers/get?year={year}&inputShape={inputShape}')
query = URI.encode_www_form({
# Request parameters
'env:outSR' => '4326'
})
if query.length > 0
if uri.query && uri.query.length > 0
uri.query += '&' + query
else
uri.query = query
end
end
request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# 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