SSURGO Soil (Trial)

The SSURGO Soils API provides soil type and average of the soil type attribute (e.g., NCCPI) by field for a shape entered.

** Please note, if you see the message "no operation selected", please refresh the page.

Post Request SSURGO Soils


Please note, this is the trial version of this API. Please purchase a subscription key for continued use.

Back to Subscription Version

This API is utilized to drive the Ag-Analytics SSURGO soil panel below, for illustration. Area calculations from the API are provided in square meters and can be easily converted to acres on the front-end. The API Response contains shapes/features in ESRI JSON format, as well as the calculated metric (e.g., National Commodity Crop Productivity Index) and areas of each shape, the soil type name, the area for the sums of each soil type across all features for display in the table, metadata related to projection and other information. This API can be easily called and mapped using any standard front-end JavaScript mapping library (e.g., Leaflet).


SSURGO Soils and NCCPI 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? Default Options Description
inputShape Esri Geometry Yes -- See esriGeometryType
Constants
The shape information for the field,
as an Esri Geometry object
inputFields String Yes aws0_5 See full
NRCS list
The soil metric to return, see the NRCS variables
PDF for full list with descriptions.
f String Yes json json/pjson Response format.
env:outSR Number Yes 4326 See WKID list The well-known ID of the
desired spatial reference.



Call API

Request

Request URL

Request headers

  • (optional)
    string

Request body

inputShape (ESRI Polygon shape): The inputShape should have the Albers (“wkid”: 5070) spatial reference. The shape information for field is esriGeometryPolygon format. Standard open source JavaScript front-end libraries (e.g., Leaflet) can be used to structure the shape. See example request below, in which "spatialReference": {"wkid": 5070} is required
inputFields (string): The metrics to return with the format “TableName_SoilTypeName”

inputShape={"geometryType":"esriGeometryPolygon","features":[{"geometry":{"rings":[[[-117.238391742523,47.361909235884],[-117.238411501866,47.3666540718942],[-117.238104754146,47.3667759852526],[-117.237319049869,47.3670230954214],[-117.236502184832,47.3672180544179],[-117.235661598881,47.3673590381549],[-117.234805056156,47.3674447833694],[-117.233940328881,47.3674745225006],[-117.233075399484,47.3674479313533],[-117.229969230047,47.3672509033416],[-117.229356757788,47.3672212024152],[-117.22853778171,47.3672224679418],[-117.227723359192,47.3672812881216],[-117.227682312472,47.3672871989753],[-117.227679393845,47.361915157684],[-117.238391742523,47.361909235884]],[[-117.238412821491,47.3669707991394],[-117.238415162501,47.3675329177202],[-117.23836557909,47.3675462695532],[-117.238147889449,47.3676624203185],[-117.237943109497,47.3677611967894],[-117.237667547691,47.3679827628098],[-117.237328008768,47.3682945667015],[-117.237167413351,47.3683370558738],[-117.235936548037,47.3683403893704],[-117.235406151252,47.3683001002252],[-117.235154584345,47.3682849987845],[-117.234879172557,47.3683040762091],[-117.234607729526,47.3683570355562],[-117.232721607891,47.3688442182915],[-117.232516017658,47.3688941350618],[-117.232282382022,47.3689218625919],[-117.231444584442,47.3689637471116],[-117.23072185566,47.3689532429787],[-117.227683127244,47.3687289626645],[-117.227682461592,47.3675684873122],[-117.227860990975,47.3675442842706],[-117.228597121723,47.3674949095447],[-117.229336828664,47.3674950166272],[-117.22993174874,47.3675238856855],[-117.233037934347,47.3677209138943],[-117.23394144908,47.3677486493423],[-117.234844729352,47.3677176107795],[-117.235739513359,47.3676280299109],[-117.236617581515,47.3674807436285],[-117.237470878627,47.3672771155391],[-117.238291599234,47.3670189848782],[-117.238412821491,47.3669707991394]]
,[[-117.23515564795,47.3683951410649],[-117.235390077697,47.3684092039139],[-117.235927869413,47.3684500575822],[-117.236804847014
,47.3684477109369],[-117.236812404541,47.3702758170121],[-117.2384265738,47.3702727251689],[-117.238452279092,47.3764430152127],[-117.227687263087,47.3764376942387],[-117.227683192821,47.3688392932326],[-117.230711395677,47.369062799795],[-117.231448818202,47.3690734961619],[-117.232302264435,47.3690308469639],[-117.232557405738,47.3690005654039],[-117.232777461542,47.3689471011173],[-117.234658812225,47.3684611927385],[-117.234909864397,47.3684121954782],[-117.23515564795,47.3683951410649]]],"spatialReference":{"wkid":4326}}}]}
&inputFields=nccpi2all&env:outSR=4326&env:processSR=&returnZ=false&returnM=false&f=pjson

Responses

200 OK

Code samples

@ECHO OFF

curl -v -X POST "https://ag-analytics.azure-api.net/ssurgosoil-clone/post"
-H "Content-Type: application/x-www-form-urlencoded"

--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/ssurgosoil-clone/post?" + 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/ssurgosoil-clone/post");


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


            // 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/ssurgosoil-clone/post?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            },
            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/ssurgosoil-clone/post";
    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/x-www-form-urlencoded" 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/ssurgosoil-clone/post');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Content-Type' => 'application/x-www-form-urlencoded',
);

$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/x-www-form-urlencoded',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('ag-analytics.azure-api.net')
    conn.request("POST", "/ssurgosoil-clone/post?%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/x-www-form-urlencoded',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('ag-analytics.azure-api.net')
    conn.request("POST", "/ssurgosoil-clone/post?%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/ssurgosoil-clone/post')


request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/x-www-form-urlencoded'
# 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