Ag-Analytics® - Boundary Service API

It is not uncommon for more than one crop to be grown on a CLU. These CLU boundaries are derived from the last publicly available distribution from 2008. A single CLU is approximately interpreted as a “field”. A Common Land Unit (CLU) is the smallest unit of land that has a permanent, contiguous boundary, a common land cover and land management, a common owner and a common producer in agricultural land associated with USDA farm programs.

The Ag-Analytics Field Boundary API provides a service which a user can pass an extent (bounding box) and retrieve field boundaries in geojson. To our knowledge, this is the only CLU field boundary data service in the market. It is a frequently requested dataset and useful for researchers who seek pre-made field boundaries in order to conduct representative analyses, as well as other apps that wish to serve ‘starter’ field boundaries.

GET Request Parameters

Note that: in the Boundary Service API, we only set up the GET request.

Parameter Type Required? Default Option Description
Geometry GeoJSON/JSON Yes 'envelope' 'envelope','point', 'line','polygon' The AOI used for searching boundaries. It can be a point(x,y coordinate pairs), a line or polygon in GeoJSON, or an envelope(bounding box with xmin, xmax, ymin, ymax).
Geometry_type String Yes - - The geometry type of the geometry passed in the request.
In [16]:
# required libraries
import requests
import json

GET request examples

0.Headers

In [17]:
# Basic Header Pattern.
headers=None
# Header for using a subscription key.
# headers={'Ocp-Apim-Subscription-Key': "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}

1.Search CLU with a polygon in geojson

In [18]:
polygon_geojson = '{"geometryType": "esriGeometryPolygon", "features": [{"geometry": {"rings": [[[-91.53900737389114, 34.55980772414722], [-91.53894861128936, 34.560481053757655], [-91.53892673258258, 34.56192576336332], [-91.53889249809026, 34.56325987524309], [-91.5388720178293, 34.564625711607334], [-91.53882557593954, 34.566462376337654], [-91.53913423046032, 34.566538207172584], [-91.53917447152463, 34.566730301462314], [-91.53962869840569, 34.566740245266146], [-91.54305890694297, 34.56681730907161], [-91.54305614512498, 34.566585087032195], [-91.54304565183531, 34.56613185570063], [-91.54306887772651, 34.56417543544802], [-91.54310131717199, 34.562940478320456], [-91.54309762365637, 34.56170736210515], [-91.54308258968973, 34.561319449433086], [-91.54285584362225, 34.56111836821816], [-91.54218857094577, 34.56094358497853], [-91.54135688960872, 34.560665392294084], [-91.54036096688509, 34.56031309277506], [-91.53965887605625, 34.560065743239534], [-91.53900737389114, 34.55980772414722]]], "spatialReference": {"wkid": 4326}}}]}'
Geometry_type = 'polygon'
params = {
    "Geometry":polygon_geojson,
    "Geometry_type":Geometry_type}

2.Search CLU with an envelope(bounding box)

In [27]:
envelope = '{"xmin": -101.79931651625, "ymin": 37.45741810262938, "xmax": -101.70931640625, "ymax": 37.45751810262938,"spatialReference": {"wkid": 4326}}'
Geometry_type = 'envelope'
params = {
    "Geometry":envelope,
    "Geometry_type":Geometry_type}

3.Search CLU with a point(x,y coords pair)

In [20]:
aoi_point = '{"x":-91.53900737389114,"y": 34.55980772414722}'
Geometry_type = 'point'
params = {
    "Geometry":aoi_point,
    "Geometry_type":Geometry_type}

GET request function

In [25]:
def Get_Boundaries(params, headers):
    API_URL = "https://ag-analytics.azure-api.net/CommonLandUnitBoundary-v2"
    response = requests.get(API_URL, params = params,headers = headers)
    if response.status_code == 200:
        print('----- API Call Succeed ----')
        print(response.text)
        return response.json()
    else:
        print('----- API Call Failed ----')
        print(response.text)
        
    
In [29]:
# Call Boundary Service API
resp = Get_Boundaries(params, headers)
----- API Call Succeed ----
{"msg":"Found 13 results","results":{"crs":{"properties":{"name":"EPSG:4326"},"type":"name"},"features":[{"geometry":{"coordinates":[[[-101.78961088123714,37.461310953138025],[-101.78961144511209,37.461294494645244],[-101.7985410286455,37.46140816895189],[-101.79850997325661,37.457531276147506],[-101.79848254843085,37.454104472443476],[-101.79841264772546,37.4541947418939],[-101.7984059145013,37.455092100719924],[-101.79821392813022,37.455179046276044],[-101.79774520237913,37.45523592749612],[-101.79760400342201,37.45576111268525],[-101.79763844385906,37.456684961042185],[-101.79771076104277,37.45954879903792],[-101.7975984024443,37.45961554672016],[-101.79326633037681,37.45955331003728],[-101.79308920530252,37.45973144684882],[-101.79312209710707,37.46123210417829],[-101.78959380401079,37.46120737102342],[-101.78959478876845,37.4612834087024],[-101.7895951368061,37.46131071211971],[-101.78961088123714,37.461310953138025]]],"type":"Polygon"},"id":8180685,"properties":{"CALCACRES":33.59999847,"CALCACRES2":null,"OBJECTID":8180685},"type":"Feature"},{"geometry":{"coordinates":[[[-101.74400772437696,37.46117945876506],[-101.74403967728927,37.46117904957356],[-101.74403960984006,37.4611725546697],[-101.74400395711689,37.45408810837955],[-101.74400382311791,37.454062510976144],[-101.73538891686496,37.45400727101878],[-101.7353889096704,37.45401265975647],[-101.73537285857054,37.454012625582266],[-101.73518640932531,37.46121106813632],[-101.73518816120463,37.461223480579235],[-101.73519320280406,37.461223481478555],[-101.74400772437696,37.46117945876506]]],"type":"Polygon"},"id":8180687,"properties":{"CALCACRES":152.11999512,"CALCACRES2":null,"OBJECTID":8180687},"type":"Feature"},{"geometry":{"coordinates":[[[-101.73537285857054,37.454012625582266],[-101.7262327734237,37.4539923989301],[-101.72617678702909,37.4612449051283],[-101.73518816120463,37.461223480579235],[-101.73518640932531,37.46121106813632],[-101.73537285857054,37.454012625582266]]],"type":"Polygon"},"id":8181450,"properties":{"CALCACRES":159.33999634,"CALCACRES2":null,"OBJECTID":8181450},"type":"Feature"},{"geometry":{"coordinates":[[[-101.78959380401079,37.46120737102342],[-101.79312209710707,37.46123210417829],[-101.79308920530252,37.45973144684882],[-101.79326633037681,37.45955331003728],[-101.7975984024443,37.45961554672016],[-101.79771076104277,37.45954879903792],[-101.79763844385906,37.456684961042185],[-101.79760400342201,37.45576111268525],[-101.79774520237913,37.45523592749612],[-101.79821392813022,37.455179046276044],[-101.7984059145013,37.455092100719924],[-101.79841264772546,37.4541947418939],[-101.79848254843085,37.454104472443476],[-101.79842569868703,37.44699851077269],[-101.7902047323625,37.44694247131804],[-101.79010826748254,37.44704883593511],[-101.78955935547981,37.4486547930843],[-101.78948872902157,37.45409415632031],[-101.78959380401079,37.46120737102342]]],"type":"Polygon"},"id":8180950,"properties":{"CALCACRES":277.6000061,"CALCACRES2":null,"OBJECTID":8180950},"type":"Feature"},{"geometry":{"coordinates":[[[-101.80752433408071,37.45423536606933],[-101.79862761087549,37.45409989939088],[-101.79862183992594,37.457494789752786],[-101.79850997325661,37.457531276147506],[-101.7985410286455,37.46140816895189],[-101.79855249680026,37.46140831194407],[-101.79855249949821,37.461397787178214],[-101.8070735435092,37.46152218050429],[-101.80762623176514,37.46151177984484],[-101.80752433408071,37.45423536606933]]],"type":"Polygon"},"id":8183426,"properties":{"CALCACRES":159.5,"CALCACRES2":null,"OBJECTID":8183426},"type":"Feature"},{"geometry":{"coordinates":[[[-101.74403960984006,37.4611725546697],[-101.75246208725548,37.46116962018186],[-101.75246929262374,37.46085664441864],[-101.7522055214676,37.460203277059634],[-101.75160854519817,37.45896506528561],[-101.75119157273286,37.45805719068687],[-101.7508830540097,37.45749089029243],[-101.75083023142997,37.457358298746556],[-101.75087185115495,37.45718528177537],[-101.7510152507532,37.45717238999384],[-101.75110225926181,37.457256381277034],[-101.75104621800853,37.45736282773237],[-101.75094399566882,37.45751814424699],[-101.75107149435394,37.45772545416645],[-101.7514360012704,37.45851029071741],[-101.75176036424938,37.45918136932477],[-101.75209883039668,37.459909464050554],[-101.75239678658238,37.46051424014013],[-101.75255455554827,37.460892890694424],[-101.75312384169189,37.46088818813945],[-101.75319446095557,37.45410196063705],[-101.75319505990404,37.454043113498926],[-101.74402252991581,37.454056624014015],[-101.74402245797,37.4540626998338],[-101.74400382311791,37.454062510976144],[-101.74400395711689,37.45408810837955],[-101.74403960984006,37.4611725546697]]],"type":"Polygon"},"id":8183652,"properties":{"CALCACRES":157.0,"CALCACRES2":null,"OBJECTID":8183652},"type":"Feature"},{"geometry":{"coordinates":[[[-101.75246208725548,37.46116962018186],[-101.75311187891003,37.46116937646559],[-101.75312103670643,37.46115801622949],[-101.75312384169189,37.46088818813945],[-101.75255455554827,37.460892890694424],[-101.75239678658238,37.46051424014013],[-101.75209883039668,37.459909464050554],[-101.75176036424938,37.45918136932477],[-101.7514360012704,37.45851029071741],[-101.75107149435394,37.45772545416645],[-101.75094399566882,37.45751814424699],[-101.75104621800853,37.45736282773237],[-101.75110225926181,37.457256381277034],[-101.7510152507532,37.45717238999384],[-101.75087185115495,37.45718528177537],[-101.75083023142997,37.457358298746556],[-101.7508830540097,37.45749089029243],[-101.75119157273286,37.45805719068687],[-101.75160854519817,37.45896506528561],[-101.7522055214676,37.460203277059634],[-101.75246929262374,37.46085664441864],[-101.75246208725548,37.46116962018186]]],"type":"Polygon"},"id":8183651,"properties":{"CALCACRES":0.97000003,"CALCACRES2":null,"OBJECTID":8183651},"type":"Feature"},{"geometry":{"coordinates":[[[-101.75312103670643,37.46115801622949],[-101.76194822523036,37.461218794212016],[-101.76200979641493,37.45400580062727],[-101.75319505990404,37.454043113498926],[-101.75319446095557,37.45410196063705],[-101.75312384169189,37.46088818813945],[-101.75312103670643,37.46115801622949]]],"type":"Polygon"},"id":8183649,"properties":{"CALCACRES":153.44000244,"CALCACRES2":null,"OBJECTID":8183649},"type":"Feature"},{"geometry":{"coordinates":[[[-101.77591437734662,37.46122327373513],[-101.77594132643105,37.46122326204397],[-101.77595099953896,37.46062888841254],[-101.77598895722457,37.457814694792376],[-101.78057758608668,37.45783588012182],[-101.78067773458974,37.45406132207239],[-101.77850429263896,37.45404767396104],[-101.77841003739326,37.45404708940168],[-101.77836967312186,37.4540470561268],[-101.77786584323405,37.45458770785649],[-101.77690692581393,37.455647368231496],[-101.77541413935103,37.457333495444516],[-101.77140961925846,37.45738644842589],[-101.77138245613543,37.461192641027594],[-101.7713822349022,37.4612252207674],[-101.77591437734662,37.46122327373513]]],"type":"Polygon"},"id":8182705,"properties":{"CALCACRES":78.37000275,"CALCACRES2":null,"OBJECTID":8182705},"type":"Feature"},{"geometry":{"coordinates":[[[-101.78328454544538,37.46121491723471],[-101.7895951368061,37.46131071211971],[-101.78959478876845,37.4612834087024],[-101.78959380401079,37.46120737102342],[-101.78948872902157,37.45409415632031],[-101.7827363070349,37.45404214313044],[-101.7826584167525,37.45456921779521],[-101.78245818719557,37.455363564676816],[-101.78252495556222,37.45600285045123],[-101.78239707376588,37.45797422283215],[-101.78222545074391,37.458378803539006],[-101.780624861648,37.45841650491781],[-101.78048002313454,37.461109429456656],[-101.78047649779211,37.461175076368704],[-101.78328454544538,37.46121491723471]]],"type":"Polygon"},"id":8182144,"properties":{"CALCACRES":136.16999817,"CALCACRES2":null,"OBJECTID":8182144},"type":"Feature"},{"geometry":{"coordinates":[[[-101.780624861648,37.45841650491781],[-101.78222545074391,37.458378803539006],[-101.78239707376588,37.45797422283215],[-101.78252495556222,37.45600285045123],[-101.78245818719557,37.455363564676816],[-101.7826584167525,37.45456921779521],[-101.7827363070349,37.45404214313044],[-101.7807618526773,37.45402686544753],[-101.78073738212447,37.456324287935615],[-101.780624861648,37.45841650491781]]],"type":"Polygon"},"id":8180691,"properties":{"CALCACRES":18.86000061,"CALCACRES2":null,"OBJECTID":8180691},"type":"Feature"},{"geometry":{"coordinates":[[[-101.77134314227214,37.46123127410408],[-101.77138223040555,37.4612309152746],[-101.7713822349022,37.4612252207674],[-101.77138245613543,37.461192641027594],[-101.77140961925846,37.45738644842589],[-101.77138179513372,37.454073200317964],[-101.77142235275932,37.44684879073918],[-101.77142241481255,37.44682965856197],[-101.764430131945,37.44679344196385],[-101.76432392920594,37.44679289067943],[-101.76435197995988,37.4497927052692],[-101.76448116037722,37.44979037512576],[-101.76473445173355,37.449985020792155],[-101.7650474023157,37.45068722853284],[-101.76492879972432,37.45175429302623],[-101.76233698056717,37.45181681209624],[-101.76237820818773,37.46115692355323],[-101.76237852025247,37.46122771548676],[-101.77134314227214,37.46123127410408]]],"type":"Polygon"},"id":8183411,"properties":{"CALCACRES":289.82000732,"CALCACRES2":null,"OBJECTID":8183411},"type":"Feature"},{"geometry":{"coordinates":[[[-101.70798268994912,37.46130227647893],[-101.72600188507892,37.46121934189915],[-101.72594653180698,37.45397591075971],[-101.71748454897272,37.45401344846192],[-101.71746966159554,37.45476047571543],[-101.71698156444762,37.45476026257609],[-101.71696702510809,37.454013281188054],[-101.70796863354559,37.45403517248525],[-101.70796863714287,37.4540352714107],[-101.70798257123863,37.46129085329028],[-101.70798268994912,37.46130227647893]]],"type":"Polygon"},"id":8181590,"properties":{"CALCACRES":315.95999146,"CALCACRES2":null,"OBJECTID":8181590},"type":"Feature"}],"type":"FeatureCollection"},"status":"SUCCEED"}

Visualize result boundaries

In [21]:
# required library
import folium
import mplleaflet
In [30]:
#Display parcels on map
result_geojson = resp['results']
zoom_point=result_geojson['features'][0]['geometry']['coordinates'][0][0]
zoom_point
m = folium.Map([zoom_point[1],zoom_point[0]],tiles='Cartodb Positron', zoom_start=11,width='70%', height='100%')
for shape in result_geojson['features']:
    folium.GeoJson(shape).add_to(m)
m
Out[30]:
Make this Notebook Trusted to load map: File -> Trust Notebook