Skip to main content

Crop Id APS

Disclaimer

The example Python source code is meant merely as a starting point to quickly interact and retrieve insights from ADMA. It is in no way intended for production workloads.

Crop Id

Once you have successfully created a Party, Farm and Field, you can use the Crop Id service to create a crop ID prediction. This is a four-step process due to the asynchronous nature of the service. These four steps have been captured and automated in tutorial/example/crop-id.py included in the downloadable tutorial zipfile.

image

  1. Submit a job request for a specific Party, Field, and inclusive Start and End years. The JSON for the request looks like the following. Note that in this case resourceId is the fieldId as indicated by the resourceType.
{
"requestPath": "/v1/crop-id/job-name-1",
"partnerRequestBody": {
"partyId": "party1",
"startYear": "2021",
"endYear": "2023",
"resourceType": "Field",
"resourceId": "field1"
}
}
  1. Poll for the status of the job until the status of the job is SUCCEEDED.
  2. Use the insightId included in the successful status response to retrieve the insight attachment ID.
  3. Use the retrieved insight Attachment ID to download the attachment containing the predictions for all years.

Before we execute the tutorial command that wraps these steps, a little explanation is in order. A new directory will be created in the root of the adma directory named output. Within the output directory, the following directory structure will be created: party_id/resource_id/solution_id. This directory will hold a file of the submitted request and its subsequent response. In the following example the file is named crop-id_2024-08-30T12_52_44.txt. This directory will also hold the generated crop-id insight json file.

Output Directory Structure

output
└── [your_party]
└── [your_field]
└── bayerAgPowered.cropid
├── crop-id_2024-08-30T12_52_44-ecc02698-c5f3-4587-a7ad-79a5c5e87624.json
└── crop-id_2024-08-30T12_52_44.txt

Generate Crop Id Insight

Note that you will need to replace the party_id and field_id "REPLACE_ME" values with your own party_id and field_id in tutorial/example/crop-id.py to generate and retrieve the insight and its attachments.

Note this command will take a few seconds to complete. The command is complete when it prints the message "Completed crop-id request".

adma> python -m tutorial.example.crop-id

An example generated crop-id insight follows.

{
"calculated_representative_point": {
"lat": 41.64569965438514,
"lon": -93.92756291287111
},
"cropid_summary": [
{
"area_hectares": 23.311475,
"crop_name": "soybeans",
"crop_confidence": {
"grass": 0.0044,
"other": 0.0133,
"soybeans": 0.9823
},
"crop_year": 2022,
"iou": 0.931829
}, {
"area_hectares": 23.027851,
"crop_name": "maize",
"crop_confidence": {
"grass": 0.0044,
"maize": 0.9823,
"other": 0.0133
},
"crop_year": 2023,
"iou": 0.935912
}
],
"partner_request_body": {
"model_spec": {
"endYear": 2023,
"startYear": 2022
},
"resource_id": "90c9ffec-1111-4bfc-8a52-39dacd61756c",
"resource_type": "Field"
}
}