Polaris Soils V2

Post Polaris V2

Please note, you need to purchase a subscription key to call the API. Please use the trial version to try now for a limited amount of uses before purchase.


The POLARIS Soils API offers a means to clip the POLARIS dataset to a user-provided area of interest. POLARIS provides a quantitative prediction of soil attributes (including pH, clay %, organic matter %) at different depths across the contiguous United States. It is build using machine learning algorithms that remap the Soil Survey Geographic (SSURGO) database.


Polaris Soils in Ag-Analytics DataLayers.


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 Parameter Details


Parameter Data Type Required? Default Options Description
aoi GeoJSONString,
.shp file, GeoTIFF
Yes -- -- Area of interest, in the case of GeoJSON, can be multipolygon or rings.)
Soil_Parameter String Yes -- See soil parameter
details table
Soil property to generate map of.
Depth_Range String Yes -- "0-5" "5-15"
"15-30" "30-60"
"60-100" "100-200"
Depth range in centimeters of the soil column.
Statistic String Yes -- mean, min,
max, var
Statistics provided per layer and variable.
Includes arithmetic mean, minimum, maximum, and variance.
Legend_Ranges String No 3 Any number greater than 0 PNG will have a number of colors corresponding to the number of
legend ranges passed. Each color bin is spaced evenly among the points.

Soil_Parameter Details

The following variables can be used for the "Soil_Parameter"


Variable Units Description Variable Units Description
silt % Silt percentage ksat cm/hr Saturated hydraulic conductivity
sand % Sand percentage resdt cm Depth to restriction layer
clay % Clay Percentage ph N/A Soil pH in H2O
bd g/cm3 Bulk Density om % Organic matter percentage
awc m3/m3 Available water content caco3 % Calcium carbonate percentage
theta_s m3/m3 Saturated soil water content cec meq/100g Cation exchange capacity in soil
theta_r m3/m3 Residual soil water content lambda N/A Pore size distribution index
(brooks-corey)
theta_33 m3/m3 Soil water content at field
capacity
hb cm Bubbling pressure
(brooks-corey)
theta_1500 m3/m3 Soil water content at the
wilting point
n N/A Measure of the pore size
distribution (van genuchten)
alpha cm-1 Scale parameter inversely
proportional to mean pore
diameter (van genuchten)

Response Parameters


Parameter Data Type Description
CellSize Int[ ] The output raster cell size (resolution)
CoordinateSystem String The CoordinateSystem defines the projection for the data. A projection specifies how
latitude-longitude coordinates are transformed into 2-dimension x-y coordinates.
Extent String The minimum and maximum X and Y coordinates of a bounding box.
Legend Dictionary Legend gives the following details for each range of values:
1. color: Hex color used for the soil parameter value
2. Area: Area of certain soil parameter value
3. Count: Number of pixels from the result raster of certain soil parameter value
4. CountAllPixels: Total number of pixels in the result raster
5. Max: maximum soil parameter value
6. Mean: average soil parameter value
7. Min: minimum soil parameter value
8. Area: Area of the soil parameter in acres
Max Double Maximum soil parameter value
Mean Double Average soil parameter value
Min Double Minimum soil parameter value
Percentile5 Double 5th percentile soil parameter value
Percentile95 Double 95th percentile soil parameter value
Product String The soil parameter supplied in the request (pH)
Std Double Standard deviation for the given soil parameter
pngb64 String Base64 png string
FileName String The tif file that can be downloaded



Call API

Request

Request URL

Request headers

  • (optional)
    string
  • string

Request body

aoi=%7B%22type%22%3A%22Feature%22%2C%22geometry%22%3A%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B-121.2475204%2C+45.4668127%5D%2C%5B-121.2484646%2C+45.4418262%5D%2C%5B-121.2119007%2C+45.4417660%5D%2C%5B-121.2115574%2C+45.4665117%5D%2C%5B-121.2475204%2C+45.4668127%5D%5D%5D%7D%7D&Soil_Parameter=ph&Depth_Range=15-30&Statistic=mean&Legend_Ranges=10

Responses

200 OK

Code samples

@ECHO OFF

curl -v -X POST "https://ag-analytics.azure-api.net/polaris-v2/"
-H "Content-Type: application/x-www-form-urlencoded"
-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}");

            var uri = "https://ag-analytics.azure-api.net/polaris-v2/?" + 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/polaris-v2/");


            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/x-www-form-urlencoded");
            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
        };
      
        $.ajax({
            url: "https://ag-analytics.azure-api.net/polaris-v2/?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            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/polaris-v2/";
    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 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/polaris-v2/');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Content-Type' => 'application/x-www-form-urlencoded',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$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',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('ag-analytics.azure-api.net')
    conn.request("POST", "/polaris-v2/?%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',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

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


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