This visitor submit is co-written by Lydia Lihui Zhang, Enterprise Improvement Specialist, and Mansi Shah, Software program Engineer/Knowledge Scientist, at Planet Labs. The evaluation that impressed this submit was initially written by Jennifer Reiber Kyle.
Amazon SageMaker geospatial capabilities mixed with Planet’s satellite tv for pc knowledge can be utilized for crop segmentation, and there are quite a few functions and potential advantages of this evaluation to the fields of agriculture and sustainability. In late 2023, Planet introduced a partnership with AWS to make its geospatial knowledge accessible by means of Amazon SageMaker.
Crop segmentation is the method of splitting up a satellite tv for pc picture into areas of pixels, or segments, which have related crop traits. On this submit, we illustrate tips on how to use a segmentation machine studying (ML) mannequin to determine crop and non-crop areas in a picture.
Figuring out crop areas is a core step in direction of gaining agricultural insights, and the mix of wealthy geospatial knowledge and ML can result in insights that drive choices and actions. For instance:
Making data-driven farming choices – By gaining higher spatial understanding of the crops, farmers and different agricultural stakeholders can optimize using sources, from water to fertilizer to different chemical substances throughout the season. This units the muse for decreasing waste, enhancing sustainable farming practices wherever attainable, and growing productiveness whereas minimizing environmental impression.
Figuring out climate-related stresses and tendencies – As local weather change continues to have an effect on world temperature and rainfall patterns, crop segmentation can be utilized to determine areas which can be weak to climate-related stress for local weather adaptation methods. For instance, satellite tv for pc imagery archives can be utilized to trace modifications in a crop rising area over time. These might be the bodily modifications in measurement and distribution of croplands. They may be the modifications in soil moisture, soil temperature, and biomass, derived from the completely different spectral index of satellite tv for pc knowledge, for deeper crop well being evaluation.
Assessing and mitigating injury – Lastly, crop segmentation can be utilized to rapidly and precisely determine areas of crop injury within the occasion of a pure catastrophe, which will help prioritize aid efforts. For instance, after a flood, high-cadence satellite tv for pc pictures can be utilized to determine areas the place crops have been submerged or destroyed, permitting aid organizations to help affected farmers extra rapidly.
On this evaluation, we use a Ok-nearest neighbors (KNN) mannequin to conduct crop segmentation, and we evaluate these outcomes with floor reality imagery on an agricultural area. Our outcomes reveal that the classification from the KNN mannequin is extra precisely consultant of the state of the present crop subject in 2017 than the bottom reality classification knowledge from 2015. These outcomes are a testomony to the facility of Planet’s high-cadence geospatial imagery. Agricultural fields change usually, typically a number of occasions a season, and having high-frequency satellite tv for pc imagery accessible to watch and analyze this land can present immense worth to our understanding of agricultural land and quickly-changing environments.
Planet and AWS’s partnership on geospatial ML
SageMaker geospatial capabilities empower knowledge scientists and ML engineers to construct, practice, and deploy fashions utilizing geospatial knowledge. SageMaker geospatial capabilities permit you to effectively rework or enrich large-scale geospatial datasets, speed up mannequin constructing with pre-trained ML fashions, and discover mannequin predictions and geospatial knowledge on an interactive map utilizing 3D-accelerated graphics and built-in visualization instruments. With SageMaker geospatial capabilities, you’ll be able to course of giant datasets of satellite tv for pc imagery and different geospatial knowledge to create correct ML fashions for numerous functions, together with crop segmentation, which we focus on on this submit.
Planet Labs PBC is a number one Earth-imaging firm that makes use of its giant fleet of satellites to seize imagery of the Earth’s floor every day. Planet’s knowledge is due to this fact a helpful useful resource for geospatial ML. Its high-resolution satellite tv for pc imagery can be utilized to determine numerous crop traits and their well being over time, anyplace on Earth.
The partnership between Planet and SageMaker permits clients to simply entry and analyze Planet’s high-frequency satellite tv for pc knowledge utilizing AWS’s highly effective ML instruments. Knowledge scientists can convey their very own knowledge or conveniently discover and subscribe to Planet’s knowledge with out switching environments.
Crop segmentation in an Amazon SageMaker Studio pocket book with a geospatial picture
On this instance geospatial ML workflow, we have a look at tips on how to convey Planet’s knowledge together with the bottom reality knowledge supply into SageMaker, and tips on how to practice, infer, and deploy a crop segmentation mannequin with a KNN classifier. Lastly, we assess the accuracy of our outcomes and evaluate this to our floor reality classification.
The KNN classifier used was skilled in an Amazon SageMaker Studio pocket book with a geospatial picture, and gives a versatile and extensible pocket book kernel for working with geospatial knowledge.
The Amazon SageMaker Studio pocket book with geospatial picture comes pre-installed with generally used geospatial libraries similar to GDAL, Fiona, GeoPandas, Shapely, and Rasterio, which permit the visualization and processing of geospatial knowledge immediately inside a Python pocket book atmosphere. Widespread ML libraries similar to OpenCV or scikit-learn are additionally used to carry out crop segmentation utilizing KNN classification, and these are additionally put in within the geospatial kernel.
Knowledge choice
The agricultural subject we zoom into is situated on the often sunny Sacramento County in California.
Why Sacramento? The realm and time choice for any such drawback is primarily outlined by the provision of floor reality knowledge, and such knowledge in crop kind and boundary knowledge, shouldn’t be simple to return by. The 2015 Sacramento County Land Use DWR Survey dataset is a publicly accessible dataset masking Sacramento County in that yr and gives hand-adjusted boundaries.
The first satellite tv for pc imagery we use is the Planet’s 4-band PSScene Product, which comprises the Blue, Inexperienced, Crimson, and Close to-IR bands and is radiometrically corrected to at-sensor radiance. The coefficients for correcting to at-sensor reflectance are offered within the scene metadata, which additional improves the consistency between pictures taken at completely different occasions.
Planet’s Dove satellites that produced this imagery had been launched February 14, 2017 (information launch), due to this fact they didn’t picture Sacramento County again in 2015. Nonetheless, they’ve been taking each day imagery of the world because the launch. On this instance, we accept the imperfect 2-year hole between the bottom reality knowledge and satellite tv for pc imagery. Nonetheless, Landsat 8 lower-resolution imagery might have been used as a bridge between 2015 and 2017.
Entry Planet knowledge
To assist customers get correct and actionable knowledge sooner, Planet has additionally developed the Planet Software program Improvement Equipment (SDK) for Python. It is a highly effective device for knowledge scientists and builders who need to work with satellite tv for pc imagery and different geospatial knowledge. With this SDK, you’ll be able to search and entry Planet’s huge assortment of high-resolution satellite tv for pc imagery, in addition to knowledge from different sources like OpenStreetMap. The SDK gives a Python consumer to Planet’s APIs, in addition to a no-code command line interface (CLI) answer, making it simple to include satellite tv for pc imagery and geospatial knowledge into Python workflows. This instance makes use of the Python consumer to determine and obtain imagery wanted for the evaluation.
You possibly can set up the Planet Python consumer within the SageMaker Studio pocket book with geospatial picture utilizing a easy command:
You should use the consumer to question related satellite tv for pc imagery and retrieve an inventory of accessible outcomes primarily based on the world of curiosity, time vary, and different search standards. Within the following instance, we begin by asking what number of PlanetScope scenes (Planet’s each day imagery) cowl the identical space of curiosity (AOI) that we outline earlier by means of the bottom knowledge in Sacramento, given a sure time vary between June 1 and October 1, 2017; in addition to a sure desired most cloud protection vary of 10%:
The returned outcomes present the variety of matching scenes overlapping with our space of curiosity. It additionally comprises every scene’s metadata, its picture ID, and a preview picture reference.
After a specific scene has been chosen, with specification on the scene ID, merchandise kind, and product bundles (reference documentation), you should use the next code to obtain the picture and its metadata:
This code downloads the corresponding satellite tv for pc picture to the Amazon Elastic File System (Amazon EFS) quantity for SageMaker Studio.
Mannequin coaching
After the info has been downloaded with the Planet Python consumer, the segmentation mannequin may be skilled. On this instance, a mix of KNN classification and picture segmentation methods is used to determine crop space and create georeferenced geojson options.
The Planet knowledge is loaded and preprocessed utilizing the built-in geospatial libraries and instruments in SageMaker to organize it for coaching the KNN classifier. The bottom reality knowledge for coaching is the Sacramento County Land Use DWR Survey dataset from 2015, and the Planet knowledge from 2017 is used for testing the mannequin.
Convert floor reality options to contours
To coach the KNN classifier, the category of every pixel as both crop or non-crop must be recognized. The category is decided by whether or not the pixel is related to a crop function within the floor reality knowledge or not. To make this dedication, the bottom reality knowledge is first transformed into OpenCV contours, that are then used to separate crop from non-crop pixels. The pixel values and their classification are then used to coach the KNN classifier.
To transform the bottom reality options to contours, the options should first be projected to the coordinate reference system of the picture. Then, the options are reworked into picture area, and at last transformed into contours. To make sure the accuracy of the contours, they’re visualized overlaid on the enter picture, as proven within the following instance.
To coach the KNN classifier, crop and non-crop pixels are separated utilizing the crop function contours as a masks.
The enter of KNN classifier consists of two datasets: X, a second array that gives the options to be categorized on; and y, a 1d array that gives the lessons (instance). Right here, a single categorized band is created from the non-crop and crop datasets, the place the band’s values point out the pixel class. The band and the underlying picture pixel band values are then transformed to the X and y inputs for the classifier match operate.
Practice the classifier on crop and non-crop pixels
The KNN classification is carried out with the scikit-learn KNeighborsClassifier. The variety of neighbors, a parameter vastly affecting the estimator’s efficiency, is tuned utilizing cross-validation in KNN cross-validation. The classifier is then skilled utilizing the ready datasets and the tuned variety of neighbor parameters. See the next code:
To evaluate the classifier’s efficiency on its enter knowledge, the pixel class is predicted utilizing the pixel band values. The classifier’s efficiency is especially primarily based on the accuracy of the coaching knowledge and the clear separation of the pixel lessons primarily based on the enter knowledge (pixel band values). The classifier’s parameters, such because the variety of neighbors and the space weighting operate, may be adjusted to compensate for any inaccuracies within the latter. See the next code:
Consider mannequin predictions
The skilled KNN classifier is utilized to foretell crop areas within the take a look at knowledge. This take a look at knowledge consists of areas that weren’t uncovered to the mannequin throughout coaching. In different phrases, the mannequin has no information of the world previous to its evaluation and due to this fact this knowledge can be utilized to objectively consider the mannequin’s efficiency. We begin by visually inspecting a number of areas, starting with a area that’s comparatively noisier.
The visible inspection reveals that the anticipated lessons are principally in keeping with the bottom reality lessons. There are just a few areas of deviation, which we examine additional.
Upon additional investigation, we found that a few of the noise on this area was as a result of floor reality knowledge missing the element that’s current within the categorized picture (high proper in comparison with high left and backside left). A very fascinating discovering is that the classifier identifies bushes alongside the river as non-crop, whereas the bottom reality knowledge mistakenly identifies them as crop. This distinction between these two segmentations could also be as a result of bushes shading the area over the crops.
Following this, we examine one other area that was categorized otherwise between the 2 strategies. These highlighted areas had been beforehand marked as non-crop areas within the floor reality knowledge in 2015 (high proper) however modified and proven clearly as cropland in 2017 by means of the Planetscope Scenes (high left and backside left). They had been additionally categorized largely as cropland by means of the classifier (backside proper).
Once more, we see the KNN classifier presents a extra granular end result than the bottom reality class, and it additionally efficiently captures the change taking place within the cropland. This instance additionally speaks to the worth of each day refreshed satellite tv for pc knowledge as a result of the world usually modifications a lot sooner than annual stories, and a mixed technique with ML like this will help us choose up the modifications as they occur. With the ability to monitor and uncover such modifications through satellite tv for pc knowledge, particularly within the evolving agricultural fields, gives useful insights for farmers to optimize their work and any agricultural stakeholder within the worth chain to get a greater pulse of the season.
Mannequin analysis
The visible comparability of the pictures of the anticipated lessons to the bottom reality lessons may be subjective and might’t be generalized for assessing the accuracy of the classification outcomes. To acquire a quantitative evaluation, we get hold of classification metrics through the use of scikit-learn’s classification_report operate:
The pixel classification is used to create a segmentation masks of crop areas, making each precision and recall vital metrics, and the F1 rating a very good total measure for predicting accuracy. Our outcomes give us metrics for each crop and non-crop areas within the practice and take a look at dataset. Nonetheless, to maintain issues easy, let’s take a better have a look at these metrics within the context of the crop areas within the take a look at dataset.
Precision is a measure of how correct our mannequin’s optimistic predictions are. On this case, a precision of 0.94 for crop areas signifies that our mannequin may be very profitable at appropriately figuring out areas which can be certainly crop areas, the place false positives (precise non-crop areas incorrectly recognized as crop areas) are minimized. Recall, however, measures the completeness of optimistic predictions. In different phrases, recall measures the proportion of precise positives that had been recognized appropriately. In our case, a recall worth of 0.73 for crop areas implies that 73% of all true crop area pixels are appropriately recognized, minimizing the variety of false negatives.
Ideally, excessive values of each precision and recall are most well-liked, though this may be largely depending on the applying of the case research. For instance, if we had been analyzing these outcomes for farmers seeking to determine crop areas for agriculture, we might need to give desire to the next recall than precision, with a purpose to reduce the variety of false negatives (areas recognized as non-crop areas which can be really crop areas) with a purpose to take advantage of use of the land. The F1-score serves as an total accuracy metric combining each precision and recall, and measuring the steadiness between the 2 metrics. A excessive F1-score, similar to ours for crop areas (0.82), signifies a very good steadiness between each precision and recall and a excessive total classification accuracy. Though the F1-score drops between the practice and take a look at datasets, that is anticipated as a result of the classifier was skilled on the practice dataset. An total weighted common F1 rating of 0.77 is promising and sufficient sufficient to attempt segmentation schemes on the categorized knowledge.
Create a segmentation masks from the classifier
The creation of a segmentation masks utilizing the predictions from the KNN classifier on the take a look at dataset entails cleansing up the anticipated output to keep away from small segments brought on by picture noise. To take away speckle noise, we use the OpenCV median blur filter. This filter preserves highway delineations between crops higher than the morphological open operation.
To use binary segmentation to the denoised output, we first have to convert the categorized raster knowledge to vector options utilizing the OpenCV findContours operate.
Lastly, the precise segmented crop areas may be computed utilizing the segmented crop outlines.
The segmented crop areas produced from the KNN classifier enable for exact identification of crop areas within the take a look at dataset. These segmented areas can be utilized for numerous functions, similar to subject boundary identification, crop monitoring, yield estimation, and useful resource allocation. The achieved F1 rating of 0.77 is sweet and gives proof that the KNN classifier is an efficient device for crop segmentation in distant sensing pictures. These outcomes can be utilized to additional enhance and refine crop segmentation methods, doubtlessly resulting in elevated accuracy and effectivity in crop evaluation.
Conclusion
This submit demonstrated how you should use the mix of Planet’s excessive cadence, high-resolution satellite tv for pc imagery and SageMaker geospatial capabilities to carry out crop segmentation evaluation, unlocking helpful insights that may enhance agricultural effectivity, environmental sustainability, and meals safety. Precisely figuring out crop areas permits additional evaluation on crop development and productiveness, monitoring of land use modifications, and detection of potential meals safety dangers.
Furthermore, the mix of Planet knowledge and SageMaker gives a variety of use instances past crop segmentation. The insights can allow data-driven choices on crop administration, useful resource allocation, and coverage planning in agriculture alone. With completely different knowledge and ML fashions, the mixed providing might additionally develop into different industries and use instances in direction of digital transformation, sustainability transformation, and safety.
To begin utilizing SageMaker geospatial capabilities, see Get began with Amazon SageMaker geospatial capabilities.
To be taught extra about Planet’s imagery specs and developer reference supplies, go to Planet Developer’s Middle. For documentation on Planet’s SDK for Python, see Planet SDK for Python. For extra details about Planet, together with its present knowledge merchandise and upcoming product releases, go to https://www.planet.com/.
Planet Labs PBC Ahead-Wanting Statements
Aside from the historic data contained herein, the issues set forth on this weblog submit are forward-looking statements throughout the which means of the “protected harbor” provisions of the Non-public Securities Litigation Reform Act of 1995, together with, however not restricted to, Planet Labs PBC’s potential to seize market alternative and understand any of the potential advantages from present or future product enhancements, new merchandise, or strategic partnerships and buyer collaborations. Ahead-looking statements are primarily based on Planet Labs PBC’s administration’s beliefs, in addition to assumptions made by, and data presently accessible to them. As a result of such statements are primarily based on expectations as to future occasions and outcomes and usually are not statements of truth, precise outcomes might differ materially from these projected. Elements which can trigger precise outcomes to vary materially from present expectations embrace, however usually are not restricted to the chance elements and different disclosures about Planet Labs PBC and its enterprise included in Planet Labs PBC’s periodic stories, proxy statements, and different disclosure supplies filed once in a while with the Securities and Alternate Fee (SEC) which can be found on-line at www.sec.gov, and on Planet Labs PBC’s web site at www.planet.com. All forward-looking statements mirror Planet Labs PBC’s beliefs and assumptions solely as of the date such statements are made. Planet Labs PBC undertakes no obligation to replace forward-looking statements to mirror future occasions or circumstances.
In regards to the authors
Lydia Lihui Zhang is the Enterprise Improvement Specialist at Planet Labs PBC, the place she helps join area for the betterment of earth throughout numerous sectors and a myriad of use instances. Beforehand, she was an information scientist at McKinsey ACRE, an agriculture-focused answer. She holds a Grasp of Science from MIT Know-how Coverage Program, specializing in area coverage. Geospatial knowledge and its broader impression on enterprise and sustainability have been her profession focus.
Mansi Shah is a software program engineer, knowledge scientist, and musician whose work explores the areas the place creative rigor and technical curiosity collide. She believes knowledge (like artwork!) imitates life, and is within the profoundly human tales behind the numbers and notes.
Xiong Zhou is a Senior Utilized Scientist at AWS. He leads the science workforce for Amazon SageMaker geospatial capabilities. His present space of analysis consists of laptop imaginative and prescient and environment friendly mannequin coaching. In his spare time, he enjoys working, enjoying basketball, and spending time along with his household.
Janosch Woschitz is a Senior Options Architect at AWS, specializing in geospatial AI/ML. With over 15 years of expertise, he helps clients globally in leveraging AI and ML for progressive options that capitalize on geospatial knowledge. His experience spans machine studying, knowledge engineering, and scalable distributed programs, augmented by a robust background in software program engineering and trade experience in complicated domains similar to autonomous driving.
Shital Dhakal is a Sr. Program Supervisor with the SageMaker geospatial ML workforce primarily based within the San Francisco Bay Space. He has a background in distant sensing and Geographic Data System (GIS). He’s captivated with understanding clients ache factors and constructing geospatial merchandise to unravel them. In his spare time, he enjoys mountain climbing, touring, and enjoying tennis.