Skip to content

ForestLanscapes contains all the processing worflows of the publications listed

Notifications You must be signed in to change notification settings

VasquezVicente/ForestLandscapes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ForestLandscapes

DOI

This repository contains all the workflows used for outputting the data products here listed. My name is Vicente Vasquez and I am Reseach technician in the Smithsonian Tropical Research institute in Panama. My main focus is to develop workflows for photogrammetry, instance crown segmentation and aligment of orthomosaics. Here, I present code to process images, correct global shifts in drone imagery, correct local shifts in drone imagery, vertical aligment of digital surface models, instance tree crown segmentation, and aligment of photogrammetry point clouds to lidar point clouds.

Vicente Vasquez. (2023). P-polycephalum/ForestLandscapes: segmentwise (v0.0.2-beta). Zenodo. https://doi.org/10.5281/zenodo.10380517

"Barro Colorado Island 50-ha plot 2020- 2023 crown maps: manually segmented and instance segmented."

DOI

Vasquez, V., Cushman, K., Ramos, P., Williamson, C., Villareal, P., Gomez Correa, L. F., & Muller-Landau, H. (2023). Barro Colorado Island 50-ha plot crown maps: manually segmented and instance segmented. (Version 0). Smithsonian Tropical Research Institute. https://doi.org/10.25573/data.24784053

"Time series of the Barro Colorado Island 50ha plot photogrametry orthomosaics and digital surface model captured with DJI Phantom 4 Pro drone: Globally aligned and vertically corrected."

DOI

Vasquez, V., Garcia, M., Hernandez, M., & Muller-Landau, H. (2023). Barro Colorado Island 50-ha plot aerial photogrammetry orthomosaics and digital surface models for 2018-2023: Globally and locally aligned time series. (Version 0). Smithsonian Tropical Research Institute. https://doi.org/10.25573/data.24782016

"Barro Colorado Island photogrametry products: from 2018 to 2023 collected with the eBee drone."

DOI

Garcia, M., Vasquez, V.,Muller-Landau, H. (2023). Barro Colorado whole-island aerial photogrammetry products for 2018-2023.(Version 4). Smithsonian Tropical Research Institute. https://doi.org/10.25573/data.24757284

LandscapeScripts

UAV_photogrametry.py

The script UAV_photogrametry.py is an standard processing workflow in Agisoft Metashape 2.0 python API. The script takes a mission folder containing a subdirectory called Images. It process the images using key parameters such as higuest aligning setting, build point cloud in medium setting, filter points aggressively, build digital surface model and build orthomosaic. The exports are done in coordinate reference system UTM 17 N or epsg 32617, rasters are exported as GeoTIFF and point clouds as Polygon file format (.ply). This simplified code was used to process the whole Barro colorado island flights and the 50ha plot flights.

Modules used:
    -pandas: 2.0.1                   
    -Metashape-2.0.3-cp37.cp38.cp39.cp310.cp311-none-win_amd64.whl

50ha_aligment.py

The script 50ha_aligment.py is a complete workflow and performs multiple tasks such as combining, cropping, reprojecting, aligning locally, globally and performing elevation correction. It combines the orthomosaics and digital surface models into a single raster by reprojecting the DSM's to the shape of the orthomosaics and replace the alpha band with the DSM. Note: be sure to set the 4th band to none if the RGB doesnt looks right in your visualization software.It crops all the combine products to buffered shape of the BCI 50ha plot. 20 meters were added to the xmax and ymax of the plot and 20 meters were substracted from the xmin and ymin of the plot. The code performs the same task with the LIDAR orthomosaic by adding the lidar Digital elevation model and the digital terrain model to the 4th and 5th band. All the merging, reprojection and cropping is avaliable in the code and auxiliary files are provided in the data publication. The orthomosaic from the P4P drone with theclosest date to the airborne LIDAR data collection over the 50ha plot is BCI_50ha_2023_05_23, this orthomosaic was locally aligned and the point with the higuest relaibility was used to globally align it to the Lidar orthomosaic by using the arosics module version 1.8.1, functions COREG and COREG_LOCAL. The closest date orthomosaic becomes the reference to the prior date. The prior date is aligned locally and then globally to then become the reference date to the next iteration of the for loop. The aligment is performed over the complete timeseries and it does not looses resolution. The global correction often fails for which we resort to the second point with the higuest reliability. Horizontal aligment is not perfect but it does mantain the data integrity without causing any warping and not resorting to resampling. Finally, the same iterative approach is applied to the 4th band to correct the vertical misaligment of DSM's. We first resample the LIDAR DSM to match the drone DSM, the we calculate the delta of the median of both arrays and we either substract or add it to the drone DSM array to correct the difference in elevation and reduce the discrepancies. The corrected drone DSM becomes the reference and the prior date becomes the target for aligment until the for loop is completed.

Note: local aligment is computationally intensive but it does generate nearly perfectly aligned orthomosaics of the 50ha plot. The quality of the aligment is best for contiguous dates. The data publication offers both timeseries. 

Modules used:
    -rasterio 1.2.10 py39h17c1fa0_0
    -numpy 1.25.1 pypi_0
    -geopandas 0.13.0 pypi_0
    -pandas 2.0.1 pypi_0
    -aroiscs 1.8.1
    -shapely 2.0.1 py39hd7f5953_0

crown_segmentation.py

The script crown_segmentation.py contains the complete workflow for segmentation of tree crowns and QAQC for the improved crown maps in the data publication Vasquez et al. 2023. The script contains 3 functions used for the crown segmentation workflow, first we tile_ortho() is used tile the orthomosaic by given inputs of tile size and buffer. Then we perform instance segmentation using the model sam_vit_h_4b8939.pth avaliable in the github repository https://github.com/facebookresearch/segment-anything(Krillov, 2023). The function crown_segment() takes as input a folder with tiles in Geotiff format, a shapefile with columns of GlobalID and tag for each polygon and tree respectively, and output file path. Furthemore, the function crown_avoid() removes all polygon overlaps by substracting the overlap from the polygon with the largest area.

    Modules used:
            -rasterio 1.2.10 py39h17c1fa0_0
            -numpy 1.25.1 pypi_0
            -geopandas 0.13.0 pypi_0
            -pandas 2.0.1 pypi_0
            -segement-anything 1.0 pypi_0
            -shapely 2.0.1 py39hd7f5953_0
            -opencv 4.6.0 py39hf11a4ad_3
            -pytorch 2.0.0 py3.9_cuda11.7_cudnn8_0

References

Kirillov, A., Mintun, E., Ravi, N., Mao, H., Rolland, C., Gustafson, L., Xiao, T., Whitehead, S., Berg, A. C., Lo, W.-Y., Dollár, P., & Girshick, R. (2023). Segment Anything. arXiv preprint arXiv:2304.02643.

Scheffler D, Hollstein A, Diedrich H, Segl K, Hostert P. AROSICS: An Automated and Robust Open-Source Image Co-Registration Software for Multi-Sensor Satellite Data. Remote Sensing. 2017; 9(7):676.]

Ball, J.G.C., Hickman, S.H.M., Jackson, T.D., Koay, X.J., Hirst, J., Jay, W., Archer, M., Aubry-Kientz, M., Vincent, G. and Coomes, D.A. (2023), Accurate delineation of individual tree crowns in tropical forests from aerial RGB imagery using Mask R-CNN. Remote Sens Ecol Conserv. 9(5):641-655. https://doi.org/10.1002/rse2.332

Disclaimer: I do not own, distribute, modify ,neither profit from the use of the Models developed by (Ball,2023), (Krillov, 2023), and (Scheffler, 2017). All credit for the development of the algorithms here used should go to the reference authors. I take credit for the development of a workflow to implement their algorithms with the purpose of tracking tree crowns in the Tropical forest of Panama.

About

ForestLanscapes contains all the processing worflows of the publications listed

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages