A jupyter notebook with crop analysis algorithms utilizing digital elevation models, dtm and multi-spectral imagery (R-G-B-NIR-Rededge-Thermal) from a MicaSense Altum sensor processed with DroneMapper Remote Expert.
Due to limitations on git file sizes, you will need to download the GeoTIFF data for this project from the following url: https://dronemapper.com/software/DroneMapper_CropAnalysis_Data.zip
These basic algorithms are intended to get you started and interested in multi-spectral processing and analysis.
The orthomosaic, digital elevation model, and dtm were clipped to an AOI using GlobalMapper. The shapefile plots were also generated using GlobalMapper grid tool. We highly recommend GlobalMapper for GIS work!
We cloned the MicaSense imageprocessing repository and created the
Batch Processing DroneMapper.ipynb notebook which allows you to quickly align and stack a Altum or RedEdge dataset creating the correct TIF files with EXIF/GPS metadata preserved. These stacked TIF files are then directly loaded into DroneMapper Remote Expert for processing.
This notebook assumes the user has basic knowledge of setting up their python environment, importing libraries and working inside jupyter.
View the entire Medium article here: https://medium.com/dataseries/data-science-crop-analysis-notebook-u…
In this step, the digital elevation model and 6 band orthomosaic are loaded for processing. The data is in UTM16N WGS84 projection and has a pixel size (GSD) of 5cm for the orthomosaic and 10cm for the DEM.
Next, we use the NIR and RED channels from the orthomosaic to compute a standard NDVI. The plots of interested are also loaded and displayed. Utilizing Rasterio, GeoPandas and Earthpy makes easy!
Using the NDVI we generated in the previous step, we use the RasterStats library to quickly compute zonal statistics for each of the plots. That data is stored in a GeoPandas dataframe and shown below.
Here we load the plot 2 area of interest, using the DEM we can compute zonal statistics for each plot. This gives us a canopy height reading for each pixel inside a plot.
The thermal band (6) in the processed orthomosaic shows stitching artifacts which could likely be improved using more accurate pre-processing alignment and de-distortion algorithms. You can find more information about these functions in the MicaSense imageprocessing github repository. See notes at the top of this notebook.
Using the DEM and DTM we can create a surface model with a ground reference of 0 meters. This allows us to calculate the volume for each plot and all pixels contained inside that plot. The volume is calculated from the ground (0m) to the top of the canopy for every pixel inside a plot.
Using the surface model, we load the plant count AOI and clip our raster data to it. This process allows us to segment the plants we want to count. We then create a binary mask to allow for simple processing with OpenCV blob detector. The plant blobs are shown in white on a black background in the binary image below. The detector is run and we get our plant count, next we iterate through each of the blobs to find the center point. With the pixel center of each blob we can do a xy lookup against the original raster to determine the spatial position of each plant.
Plant Count: 310