|
1 | | -# NeonTreeClassification |
| 1 | +# NEON Tree Classification |
2 | 2 |
|
3 | | -National Ecological Observatory Network (NEON) offers a variety of data products, including airborne data from different forest sites. Airborne data includes RGB orthophotos, LiDAR (CHM) airborne data, and 426 band hyperspectral data. All products are available on https://data.neonscience.org/data-products/, the following are the airborne data products used in this repository: |
| 3 | +A Python package for processing NEON (National Ecological Observatory Network) tree crown annotation data and building machine learning models for tree species classification. |
4 | 4 |
|
5 | | -rgb_data_product = 'DP3.30010.001' |
6 | | -hsi_withbrdf_2022 = 'DP3.30006.002' |
7 | | -lidar = 'DP3.30015.001' #CHM |
| 5 | +National Ecological Observatory Network (NEON) offers a variety of data products, including airborne data from different forest sites. Airborne data includes RGB orthophotos, LiDAR (CHM) airborne data, and 426 band hyperspectral data. All products are available on https://data.neonscience.org/data-products/. |
8 | 6 |
|
9 | | -# Workflow |
10 | | -## 1. Download NEON data |
11 | | -- Given the Northing, Easting, Year and Site, download the NEON data using the `download_neon_data.py` script. There are functions to download the RGB, HSI, and LiDAR data. The data is downloaded to a specified directory. |
12 | | -### To do: |
13 | | -- Merge this script in neon_utils.py |
14 | | -- Look into using Google Earth Engine |
| 7 | +## NEON Data Products Used |
15 | 8 |
|
16 | | -## 2. Generate crowns using deepforest |
17 | | -- The `deepforest_parallel.py` script uses the deepforest package to generate tree crowns from the RGB data. The script is parallelized on SLURM using Dask. It can run on a given list of RGB tiles and save a pandas dataframe with the tree crowns. |
| 9 | +- **RGB Orthophotos**: `DP3.30010.001` - High-resolution orthorectified camera imagery mosaic |
| 10 | +- **Hyperspectral Imagery**: `DP3.30006.002` - Spectrometer orthorectified surface bidirectional reflectance - mosaic |
| 11 | +- **LiDAR CHM**: `DP3.30015.001` - Ecosystem structure (Canopy Height Model) |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Shapefile Processing**: Handle coordinate system transformations and validation for NEON tree crown shapefiles |
| 16 | +- **HSI Tile Processing**: Convert and process hyperspectral imagery (HSI) tiles from H5 to GeoTIFF format |
| 17 | +- **Crown-Tile Intersection**: Match tree crown annotations with corresponding image tiles |
| 18 | +- **Data Pipeline**: End-to-end processing from raw NEON data to training-ready datasets |
| 19 | +- **Coordinate Validation**: Robust handling of invalid coordinates and CRS issues |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +```bash |
| 24 | +# Clone the repository |
| 25 | +git clone https://github.com/Ritesh313/NeonTreeClassification.git |
| 26 | +cd NeonTreeClassification |
| 27 | + |
| 28 | +# Install in development mode |
| 29 | +pip install -e . |
| 30 | +``` |
| 31 | + |
| 32 | +## Quick Start |
| 33 | + |
| 34 | +### 1. Process Shapefiles |
| 35 | +```bash |
| 36 | +python scripts/test_shapefile_processor.py |
| 37 | +``` |
| 38 | + |
| 39 | +### 2. Process Tiles and Crowns |
| 40 | +```bash |
| 41 | +python scripts/process_tiles_to_crowns.py |
| 42 | +``` |
| 43 | + |
| 44 | +## Package Structure |
| 45 | + |
| 46 | +``` |
| 47 | +neon_tree_classification/ |
| 48 | +├── data/ |
| 49 | +│ └── shapefile_processor.py # Shapefile processing and CRS handling |
| 50 | +├── models/ |
| 51 | +│ └── hsi_models.py # PyTorch models for HSI classification |
| 52 | +├── processing/ |
| 53 | +│ └── __init__.py # Processing utilities |
| 54 | +└── utils/ |
| 55 | + └── __init__.py # General utilities |
| 56 | +
|
| 57 | +scripts/ |
| 58 | +├── download_neon_all_modalities.py # Data download scripts |
| 59 | +├── process_tiles_to_crowns.py # Main processing pipeline |
| 60 | +└── test_shapefile_processor.py # Test shapefile processing |
| 61 | +
|
| 62 | +configs/ # Configuration files |
| 63 | +notebooks/ # Jupyter notebooks for analysis |
| 64 | +SLURM/ # SLURM job scripts |
| 65 | +tests/ # Unit tests |
| 66 | +``` |
| 67 | + |
| 68 | +## Workflow |
| 69 | + |
| 70 | +### 1. Download NEON Data |
| 71 | +Given the Northing, Easting, Year and Site, download the NEON data using the download scripts. There are functions to download the RGB, HSI, and LiDAR data. |
| 72 | + |
| 73 | +### 2. Process Shapefiles |
| 74 | +Process tree crown annotation shapefiles with coordinate system correction and validation. |
| 75 | + |
| 76 | +### 3. Process Tiles and Crowns |
| 77 | +Run the full pipeline to match crown annotations with image tiles and create training datasets. |
| 78 | + |
| 79 | +## Usage Examples |
| 80 | + |
| 81 | +### Processing NEON Shapefiles |
| 82 | + |
| 83 | +```python |
| 84 | +from neon_tree_classification.data.shapefile_processor import ShapefileProcessor |
| 85 | + |
| 86 | +processor = ShapefileProcessor() |
| 87 | + |
| 88 | +# Consolidate shapefiles from subdirectories |
| 89 | +processor.consolidate_files(parent_dir, destination_dir) |
| 90 | + |
| 91 | +# Process with coordinate validation and CRS correction |
| 92 | +sites_df, summary = processor.process_shapefiles(destination_dir) |
| 93 | +``` |
| 94 | + |
| 95 | +### Running the Tile Processing Pipeline |
| 96 | + |
| 97 | +```python |
| 98 | +from scripts.process_tiles_to_crowns import run_full_pipeline |
| 99 | + |
| 100 | +results = run_full_pipeline( |
| 101 | + tiles_base_dir="/path/to/neon_tiles", |
| 102 | + crown_csv_path="/path/to/clean_coordinates.csv", |
| 103 | + site="BART", |
| 104 | + year="2019", |
| 105 | + output_base_dir="/path/to/output" |
| 106 | +) |
| 107 | +``` |
| 108 | + |
| 109 | +## Key Features |
| 110 | + |
| 111 | +### Coordinate System Handling |
| 112 | +- Automatic UTM zone detection by NEON site |
| 113 | +- CRS transformation and validation |
| 114 | +- Invalid coordinate filtering (infinite values, out-of-range) |
| 115 | + |
| 116 | +### Multi-Modal Processing |
| 117 | +- RGB imagery (GeoTIFF) |
| 118 | +- Hyperspectral imagery (H5 → GeoTIFF conversion) |
| 119 | +- LiDAR CHM data (GeoTIFF) |
| 120 | + |
| 121 | +### Robust Data Validation |
| 122 | +- Geometry validation and cleaning |
| 123 | +- Coordinate range checking |
| 124 | +- File existence verification |
| 125 | +- Error handling and reporting |
| 126 | + |
| 127 | +## Contributing |
| 128 | + |
| 129 | +1. Fork the repository |
| 130 | +2. Create a feature branch |
| 131 | +3. Make your changes |
| 132 | +4. Add tests for new functionality |
| 133 | +5. Submit a pull request |
| 134 | + |
| 135 | +## Authors |
| 136 | + |
| 137 | +- Ritesh Chowdhry |
| 138 | + |
| 139 | +## Acknowledgments |
| 140 | + |
| 141 | +- National Ecological Observatory Network (NEON) for providing the data |
| 142 | +- University of Florida Macrosystems project |
18 | 143 |
|
19 | 144 | # Citations |
20 | 145 |
|
|
0 commit comments