Consuming Leaf datasets in ArcGIS Pro

27 Mar, 2024

Consuming Leaf datasets in ArcGIS Pro

Consuming Leaf datasets in ArcGIS Pro

About

This tutorial provides steps to consume Leaf geospatial data through the ArcGIS Pro toolboxes. Field boundaries, satellite images, and field operations point data can be handled directly in ArcGIS Pro.

Summary

  • Step 1: Register for a Leaf account
  • Step 2: Open the toolbox
  • Step 3: Working with the tools
        · Step 3.1: Authentication
        · Step 3.2: Crop Monitoring tools
        · Step 3.3: Magic Link
        · Step 3.4: Field Boundary
        · Step 3.5: Field Operations

1. Register for a Leaf account

First, you’ll need to register for a Leaf account. If you don’t yet have an account you can register below. Make sure to activate your account via the activation email.

Register with Leaf https://withleaf.io/account/quickstart

2. Open the toolbox

To use our samples, you can download the files from our repository on GitHub here, and open them in ArcGIS Pro from the Catalog.

Leaf, data infrastructure for agriculture

This is a sample code, so feel free to make edits as needed. Following, you will find the sample tools we have created.

3. Working with the tools

3.1. Authentication

Communication with the Leaf API requires authentication using your Leaf account, so you need to think about this when developing your toolbox.

The sample tool uses the authentication with Leaf endpoint https://docs.withleaf.io/docs/authentication.

In our sample, we add a tool that manages the authentication and stores the token in a temporary table.

The other toolboxes will check if the authentication was made and will show a "not licensed" message if it was not performed correctly.

Leaf, data infrastructure for agriculture

Note

If you want to share this with your customers, remember you should keep your Leaf credential private.

3.2. Crop Monitoring tools

Below are examples using the Crop Monitoring service from Leaf API.

3.2.1. Creating a satellite field

Since Leaf expects a geometry as a satellite field/Area of Interest (AoI), the sample toolbox can read the geometries from a feature layer available in the Pro Table of Contents. The new field(s) also requires a name/unique identifier for each geometry, which can be read from a column from the selected layer.

Leaf, data infrastructure for agriculture

Leaf enables you to fetch past images by setting a start date parameter. Sentinel and Planet are the supported providers.

Note

Planet requires activation from Leaf to be available for testing. Consult our support team.

You can find more information on how to create satellite fields using the Leaf documentation here: https://docs.withleaf.io/docs/crop_monitoring_endpoints#create-a-satellite-field.

As the Leaf API only accepts GeoJSON geometries you must convert the selected layer:

After creation, Leaf API will begin to fetch and process images from the start date forward.

3.2.2. Getting satellite images

The fields registered with Leaf are constantly monitored and for each new image the following images will be available:

  • The original multiband GeoTIFF;
  • The RGB (as GeoTIFF and PNG);
  • The NDVI and NDRE images (as GeoTIFF and PNG).

In the toolbox sample code, we use the Get all images endpoint to search for the images available for a specific timeframe.

Leaf, data infrastructure for agriculture

During the execution, the process downloads the selected GeoTIFF image. In our example we are saving it locally in a temporary folder, you can change it to the appropriate method. Remember to authenticate when using the download URL.

3.2.3. Delete satellite field

The satellite fields can be deleted using the delete endpoint; implemented in this sample code tool.

Leaf, data infrastructure for agriculture

The field deletion is performed using the Delete satellite field endpoint.

3.3. Magic Link

The Magic Link features can also be used in the ArcGIS Pro. This will facilitate the Leaf User creation and build no-code applications for provider connections or machine file upload.

3.3.1. File upload link

The creation of magic links that allow customers to upload their machine files to be processed and standardized by Leaf can easily be adapted through a toolbox.

In our example, you have the option to create a new Leaf User or to recover the already created Leaf Users. The link customizations can be open or fixed properties.

Leaf, data infrastructure for agriculture

This solution uses the magic link generation that can use a pre-existing leaf user or create a new one on-demand.

The generated link can be stored in an output parameter.

Leaf, data infrastructure for agriculture Leaf, data infrastructure for agriculture
3.3.2. Multiple Provider Authentication Link

Create a magic link that allows customers to connect to different data providers. This requires a pre-configuration for each provider available that can be done following the instructions here.

In our example, you have the option to create a new Leaf User or to recover the already created Leaf Users. The link customizations can be open or fixed properties.

Leaf, data infrastructure for agriculture

This solution uses the magic link generation that can use a pre-existing leaf user or create a new one on-demand.

The generated link can be stored in an output parameter.

3.4. Field Boundary

3.4.1. Get Field Boundaries

The Leaf API can provide Field boundaries from different providers and manage manually created boundaries as well. This is a toolbox using the Field Boundary Management service allowing the download of boundaries and their properties like the field hierarchy.

Leaf, data infrastructure for agriculture

This toolbox combines the data from different endpoints like Growers, Farms, Fields, and Field Boundary.

3.4.2. New Field Boundary

Leaf supports different file formats as input for field boundary creation such as shapefiles, GeoJSON, and KML. This can be done using the field file upload endpoint.

The file process is asynchronous, so it takes a few minutes to create the new field.

3.5. Field Operations

3.5.1. Machine Files

Leaf API can receive different types of machine files, such as thumb drive data, and mainly from different ag data providers like OEM portals. Those files are normalized and converted into a Leaf standard format.

3.5.2. Field Operations

Field Operations are the merging of machine files that occur within the same Field boundary, with configurable merging rules.

Leaf, data infrastructure for agriculture

Those operations are available in a standardGeoJSON file with all the point data with normalized and standardized properties that are also summarized in another endpoint.

The standard GeoJSON file can be downloaded and easily converted to a feature to be displayed directly in ArcGIS Pro.

The toolboxes and sample codes from this tutorial are not a Leaf product but suggestions on how to consume the Leaf API. We recommend a deep review of the codes to find the best match for each requirement.

Ready to begin?

Get API Keys and Start Building Today!

Sign up for free account

Questions? Get in touch