dronelytics 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dronelytics-1.0.1/LICENSE +21 -0
- dronelytics-1.0.1/PKG-INFO +298 -0
- dronelytics-1.0.1/README.md +276 -0
- dronelytics-1.0.1/dronelytics/__init__.py +45 -0
- dronelytics-1.0.1/dronelytics/core/__init__.py +17 -0
- dronelytics-1.0.1/dronelytics/core/extraction.py +234 -0
- dronelytics-1.0.1/dronelytics/core/indices.py +75 -0
- dronelytics-1.0.1/dronelytics/core/orthomosaic.py +77 -0
- dronelytics-1.0.1/dronelytics/core/pointcloud.py +301 -0
- dronelytics-1.0.1/dronelytics/core/segmentation.py +170 -0
- dronelytics-1.0.1/dronelytics/core/vegetation_indices_extended.py +206 -0
- dronelytics-1.0.1/dronelytics/data/__init__.py +3 -0
- dronelytics-1.0.1/dronelytics/data/structures.py +47 -0
- dronelytics-1.0.1/dronelytics/export/__init__.py +4 -0
- dronelytics-1.0.1/dronelytics/export/csv_export.py +11 -0
- dronelytics-1.0.1/dronelytics/export/excel_export.py +94 -0
- dronelytics-1.0.1/dronelytics/processing/__init__.py +3 -0
- dronelytics-1.0.1/dronelytics/processing/pipeline.py +194 -0
- dronelytics-1.0.1/dronelytics/utils/__init__.py +5 -0
- dronelytics-1.0.1/dronelytics/utils/logger.py +16 -0
- dronelytics-1.0.1/dronelytics/visualization/__init__.py +11 -0
- dronelytics-1.0.1/dronelytics/visualization/vis3d.py +203 -0
- dronelytics-1.0.1/dronelytics.egg-info/PKG-INFO +298 -0
- dronelytics-1.0.1/dronelytics.egg-info/SOURCES.txt +34 -0
- dronelytics-1.0.1/dronelytics.egg-info/dependency_links.txt +1 -0
- dronelytics-1.0.1/dronelytics.egg-info/requires.txt +9 -0
- dronelytics-1.0.1/dronelytics.egg-info/top_level.txt +3 -0
- dronelytics-1.0.1/examples/__init__.py +1 -0
- dronelytics-1.0.1/examples/advanced_workflow.py +151 -0
- dronelytics-1.0.1/examples/basic_workflow.py +98 -0
- dronelytics-1.0.1/examples/visualization_example.py +164 -0
- dronelytics-1.0.1/pyproject.toml +29 -0
- dronelytics-1.0.1/setup.cfg +4 -0
- dronelytics-1.0.1/setup.py +26 -0
- dronelytics-1.0.1/tests/__init__.py +1 -0
- dronelytics-1.0.1/tests/test_core.py +225 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Research Development
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dronelytics
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Comprehensive Python package for drone orthomosaic analysis and agricultural field phenotyping
|
|
5
|
+
Author: Lalit BC
|
|
6
|
+
Author-email: Lalit BC <lalitiaas@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: numpy
|
|
12
|
+
Requires-Dist: rasterio
|
|
13
|
+
Requires-Dist: matplotlib
|
|
14
|
+
Requires-Dist: scipy
|
|
15
|
+
Requires-Dist: pandas
|
|
16
|
+
Provides-Extra: pointcloud
|
|
17
|
+
Requires-Dist: laspy; extra == "pointcloud"
|
|
18
|
+
Requires-Dist: pyvista; extra == "pointcloud"
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
|
|
23
|
+
# Dronelytics
|
|
24
|
+
|
|
25
|
+
Comprehensive Python package for end-to-end drone orthomosaic analysis and agricultural field phenotyping.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
Dronelytics provides a complete workflow for processing multispectral drone imagery and point clouds:
|
|
30
|
+
|
|
31
|
+
- **Multispectral Orthomosaic Processing**: Load and manage 4-band (RGB+NIR) and 5-band (RGB+NIR+RedEdge) GeoTIFF files
|
|
32
|
+
- **10 Vegetation Indices**: NDVI, NDRE, GNDVI, ExG, SAVI, MSAVI, VARI, ARVI, CVI, OSAVI
|
|
33
|
+
- **Custom Formula Support**: Define your own vegetation index formulas using lambda functions
|
|
34
|
+
- **Plot Segmentation**: Automated detection and boundary extraction of crop plots
|
|
35
|
+
- **Pixel-Level Extraction**: Extract spectral data by plot or region
|
|
36
|
+
- **3D Canopy Modeling**: Generate DTM, DSM, and CHM from point clouds
|
|
37
|
+
- **3D Visualization**: Interactive and static visualization of point clouds, elevation models, and meshes
|
|
38
|
+
- **Data Export**: Save results to CSV and Excel formats
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
Install from PyPI:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install dronelytics
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For point cloud processing support (optional):
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install dronelytics[pointcloud]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This installs additional dependencies for LAS file handling and 3D mesh generation.
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
### Load Orthomosaic and Calculate Vegetation Indices
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from dronelytics import Orthomosaic, VegetationIndicesExtended
|
|
62
|
+
|
|
63
|
+
ortho = Orthomosaic('field.tif', band_config={
|
|
64
|
+
'red': 1, 'green': 2, 'blue': 3, 'nir': 4
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
vi = VegetationIndicesExtended(ortho)
|
|
68
|
+
ndvi = vi.ndvi()
|
|
69
|
+
gndvi = vi.gndvi()
|
|
70
|
+
exg = vi.exg()
|
|
71
|
+
|
|
72
|
+
print(f"NDVI Mean: {ndvi.mean:.4f}")
|
|
73
|
+
print(f"GNDVI Mean: {gndvi.mean:.4f}")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Process 5-Band Imagery with Red-Edge
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
ortho = Orthomosaic('field_5band.tif', band_config={
|
|
80
|
+
'red': 1, 'green': 2, 'blue': 3, 'nir': 4, 'rededge': 5
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
vi = VegetationIndicesExtended(ortho)
|
|
84
|
+
ndvi = vi.ndvi()
|
|
85
|
+
ndre = vi.ndre()
|
|
86
|
+
all_indices = vi.calculate_all()
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Detect Plots and Extract Data
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from dronelytics import PlotSegmentation, PixelExtraction
|
|
93
|
+
|
|
94
|
+
segmentation = PlotSegmentation(ortho)
|
|
95
|
+
seg_result = segmentation.segment_by_ndvi(ndvi.data, threshold=0.3)
|
|
96
|
+
|
|
97
|
+
extraction = PixelExtraction(ortho)
|
|
98
|
+
extract_result = extraction.extract_spectra()
|
|
99
|
+
df = extraction.to_dataframe()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Process Point Cloud and Generate CHM
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from dronelytics import PointCloudProcessor
|
|
106
|
+
|
|
107
|
+
processor = PointCloudProcessor('field.las')
|
|
108
|
+
|
|
109
|
+
chm, meta = processor.generate_chm(cell_size=1.0)
|
|
110
|
+
dtm, _ = processor.generate_dtm(cell_size=1.0)
|
|
111
|
+
dsm, _ = processor.generate_dsm(cell_size=1.0)
|
|
112
|
+
|
|
113
|
+
print(f"Mean crop height: {meta['mean_height']:.2f}m")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Visualize Results
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from dronelytics.visualization import show_chm, show_comparison
|
|
120
|
+
|
|
121
|
+
show_chm(chm, title="Crop Height Model")
|
|
122
|
+
show_comparison({'DTM': dtm, 'DSM': dsm, 'CHM': chm})
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Custom Vegetation Index
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
def my_formula(ortho):
|
|
129
|
+
nir = ortho.get_band('nir')
|
|
130
|
+
red = ortho.get_band('red')
|
|
131
|
+
return (nir - red) / (nir + red + 1e-10)
|
|
132
|
+
|
|
133
|
+
custom = vi.custom(my_formula, 'MyIndex')
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Band Configuration
|
|
137
|
+
|
|
138
|
+
Specify how bands are mapped in your GeoTIFF file:
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
band_config = {
|
|
142
|
+
'red': 1, # Band 1 is red
|
|
143
|
+
'green': 2, # Band 2 is green
|
|
144
|
+
'blue': 3, # Band 3 is blue
|
|
145
|
+
'nir': 4, # Band 4 is NIR
|
|
146
|
+
'rededge': 5 # Band 5 is red-edge (optional, 5-band only)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
ortho = Orthomosaic('field.tif', band_config=band_config)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Vegetation Indices
|
|
153
|
+
|
|
154
|
+
10 vegetation indices are implemented:
|
|
155
|
+
|
|
156
|
+
| Index | Formula | Use Case |
|
|
157
|
+
|-------|---------|----------|
|
|
158
|
+
| NDVI | (NIR - RED) / (NIR + RED) | Vegetation health, stress detection |
|
|
159
|
+
| NDRE | (NIR - RedEdge) / (NIR + RedEdge) | Nitrogen content (5-band only) |
|
|
160
|
+
| GNDVI | (NIR - GREEN) / (NIR + GREEN) | Chlorophyll content |
|
|
161
|
+
| ExG | 2*GREEN - RED - BLUE | Greenness index for RGB imagery |
|
|
162
|
+
| SAVI | ((NIR - RED) / (NIR + RED + L)) * (1 + L) | Soil adjustment (L=0.5) |
|
|
163
|
+
| MSAVI | Modified SAVI | Improved soil adjustment |
|
|
164
|
+
| VARI | (GREEN - RED) / (GREEN + RED - BLUE) | Visible atmospherically resistant |
|
|
165
|
+
| ARVI | (NIR - (2*RED - BLUE)) / (NIR + (2*RED - BLUE)) | Atmospheric correction |
|
|
166
|
+
| CVI | (NIR / GREEN) * (RED / GREEN) | Chlorophyll |
|
|
167
|
+
| OSAVI | Optimized SAVI with Y=0.16 | Better soil adjustment |
|
|
168
|
+
|
|
169
|
+
## 3D Visualization Functions
|
|
170
|
+
|
|
171
|
+
The visualization module (3dVis) provides 5 simple functions:
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from dronelytics.visualization import (
|
|
175
|
+
show_pointcloud, # Visualize point cloud with classification
|
|
176
|
+
show_dem, # Visualize elevation models (DTM, DSM)
|
|
177
|
+
show_chm, # Visualize crop height model
|
|
178
|
+
show_mesh, # Visualize 3D surface mesh
|
|
179
|
+
show_comparison # Compare multiple elevation models
|
|
180
|
+
)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## File Structure
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
dronelytics/
|
|
187
|
+
├── core/ # Core modules
|
|
188
|
+
│ ├── orthomosaic.py # Orthomosaic loading and management
|
|
189
|
+
│ ├── indices.py # Standard vegetation indices
|
|
190
|
+
│ ├── vegetation_indices_extended.py # 10 indices + custom formulas
|
|
191
|
+
│ ├── segmentation.py # Plot boundary detection
|
|
192
|
+
│ ├── extraction.py # Pixel-level data extraction
|
|
193
|
+
│ └── pointcloud.py # Point cloud processing, DTM/DSM/CHM
|
|
194
|
+
│
|
|
195
|
+
├── visualization/ # 3D visualization (3dVis)
|
|
196
|
+
│ └── vis3d.py # 5 visualization functions
|
|
197
|
+
│
|
|
198
|
+
├── export/ # Data export
|
|
199
|
+
│ ├── csv_export.py # CSV export
|
|
200
|
+
│ └── excel_export.py # Excel export
|
|
201
|
+
│
|
|
202
|
+
├── processing/ # Analysis pipelines
|
|
203
|
+
│ └── pipeline.py # Orchestrate analysis workflow
|
|
204
|
+
│
|
|
205
|
+
├── data/ # Data structures
|
|
206
|
+
│ └── structures.py # VegetationIndexData, SegmentationResult, etc.
|
|
207
|
+
│
|
|
208
|
+
└── utils/ # Utilities
|
|
209
|
+
└── logger.py # Clean logging (no decorative symbols)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Examples
|
|
213
|
+
|
|
214
|
+
### Basic Workflow
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
python examples/basic_workflow.py
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Advanced Workflow (5-band, Point Cloud)
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
python examples/advanced_workflow.py
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 3D Visualization
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
python examples/visualization_example.py
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Requirements
|
|
233
|
+
|
|
234
|
+
- Python 3.7+
|
|
235
|
+
- numpy
|
|
236
|
+
- rasterio (GeoTIFF support)
|
|
237
|
+
- matplotlib (visualization)
|
|
238
|
+
- scipy (segmentation)
|
|
239
|
+
- pandas (data extraction)
|
|
240
|
+
|
|
241
|
+
Optional dependencies:
|
|
242
|
+
- laspy (LAS/LAZ file support)
|
|
243
|
+
- pyvista (3D mesh and interactive visualization)
|
|
244
|
+
|
|
245
|
+
## Testing
|
|
246
|
+
|
|
247
|
+
Run unit tests:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
python -m pytest tests/test_core.py
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Or use the test module directly:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
python tests/test_core.py
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## CHM Calculation
|
|
260
|
+
|
|
261
|
+
Crop Height Model (CHM) is calculated as:
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
CHM = DSM - DTM
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Where:
|
|
268
|
+
- DSM: Digital Surface Model (top of vegetation)
|
|
269
|
+
- DTM: Digital Terrain Model (ground surface)
|
|
270
|
+
- CHM: Height of vegetation above ground
|
|
271
|
+
|
|
272
|
+
## Documentation
|
|
273
|
+
|
|
274
|
+
- `WORKFLOW.md`: Complete analysis workflow guide
|
|
275
|
+
- `VISUALIZATION_GUIDE.md`: 3D visualization usage
|
|
276
|
+
- `5BAND_SUPPORT_GUIDE.md`: Red-edge band support
|
|
277
|
+
- `COMPLETE_FEATURE_SUMMARY.md`: Feature overview
|
|
278
|
+
- `DEPLOYMENT_CHECKLIST.md`: Production deployment guide
|
|
279
|
+
|
|
280
|
+
## License
|
|
281
|
+
|
|
282
|
+
MIT License. See LICENSE file for details.
|
|
283
|
+
|
|
284
|
+
## Citation
|
|
285
|
+
|
|
286
|
+
If you use Dronelytics in your research, please cite:
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
Dronelytics v1.0.0 - Comprehensive drone orthomosaic analysis package
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Support
|
|
293
|
+
|
|
294
|
+
For issues, feature requests, or questions, please refer to the documentation files or create an issue on GitHub.
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
Made for agricultural field phenotyping and precision agriculture research.
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# Dronelytics
|
|
2
|
+
|
|
3
|
+
Comprehensive Python package for end-to-end drone orthomosaic analysis and agricultural field phenotyping.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
Dronelytics provides a complete workflow for processing multispectral drone imagery and point clouds:
|
|
8
|
+
|
|
9
|
+
- **Multispectral Orthomosaic Processing**: Load and manage 4-band (RGB+NIR) and 5-band (RGB+NIR+RedEdge) GeoTIFF files
|
|
10
|
+
- **10 Vegetation Indices**: NDVI, NDRE, GNDVI, ExG, SAVI, MSAVI, VARI, ARVI, CVI, OSAVI
|
|
11
|
+
- **Custom Formula Support**: Define your own vegetation index formulas using lambda functions
|
|
12
|
+
- **Plot Segmentation**: Automated detection and boundary extraction of crop plots
|
|
13
|
+
- **Pixel-Level Extraction**: Extract spectral data by plot or region
|
|
14
|
+
- **3D Canopy Modeling**: Generate DTM, DSM, and CHM from point clouds
|
|
15
|
+
- **3D Visualization**: Interactive and static visualization of point clouds, elevation models, and meshes
|
|
16
|
+
- **Data Export**: Save results to CSV and Excel formats
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
Install from PyPI:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install dronelytics
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
For point cloud processing support (optional):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install dronelytics[pointcloud]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This installs additional dependencies for LAS file handling and 3D mesh generation.
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
### Load Orthomosaic and Calculate Vegetation Indices
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from dronelytics import Orthomosaic, VegetationIndicesExtended
|
|
40
|
+
|
|
41
|
+
ortho = Orthomosaic('field.tif', band_config={
|
|
42
|
+
'red': 1, 'green': 2, 'blue': 3, 'nir': 4
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
vi = VegetationIndicesExtended(ortho)
|
|
46
|
+
ndvi = vi.ndvi()
|
|
47
|
+
gndvi = vi.gndvi()
|
|
48
|
+
exg = vi.exg()
|
|
49
|
+
|
|
50
|
+
print(f"NDVI Mean: {ndvi.mean:.4f}")
|
|
51
|
+
print(f"GNDVI Mean: {gndvi.mean:.4f}")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Process 5-Band Imagery with Red-Edge
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
ortho = Orthomosaic('field_5band.tif', band_config={
|
|
58
|
+
'red': 1, 'green': 2, 'blue': 3, 'nir': 4, 'rededge': 5
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
vi = VegetationIndicesExtended(ortho)
|
|
62
|
+
ndvi = vi.ndvi()
|
|
63
|
+
ndre = vi.ndre()
|
|
64
|
+
all_indices = vi.calculate_all()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Detect Plots and Extract Data
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from dronelytics import PlotSegmentation, PixelExtraction
|
|
71
|
+
|
|
72
|
+
segmentation = PlotSegmentation(ortho)
|
|
73
|
+
seg_result = segmentation.segment_by_ndvi(ndvi.data, threshold=0.3)
|
|
74
|
+
|
|
75
|
+
extraction = PixelExtraction(ortho)
|
|
76
|
+
extract_result = extraction.extract_spectra()
|
|
77
|
+
df = extraction.to_dataframe()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Process Point Cloud and Generate CHM
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from dronelytics import PointCloudProcessor
|
|
84
|
+
|
|
85
|
+
processor = PointCloudProcessor('field.las')
|
|
86
|
+
|
|
87
|
+
chm, meta = processor.generate_chm(cell_size=1.0)
|
|
88
|
+
dtm, _ = processor.generate_dtm(cell_size=1.0)
|
|
89
|
+
dsm, _ = processor.generate_dsm(cell_size=1.0)
|
|
90
|
+
|
|
91
|
+
print(f"Mean crop height: {meta['mean_height']:.2f}m")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Visualize Results
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from dronelytics.visualization import show_chm, show_comparison
|
|
98
|
+
|
|
99
|
+
show_chm(chm, title="Crop Height Model")
|
|
100
|
+
show_comparison({'DTM': dtm, 'DSM': dsm, 'CHM': chm})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Custom Vegetation Index
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
def my_formula(ortho):
|
|
107
|
+
nir = ortho.get_band('nir')
|
|
108
|
+
red = ortho.get_band('red')
|
|
109
|
+
return (nir - red) / (nir + red + 1e-10)
|
|
110
|
+
|
|
111
|
+
custom = vi.custom(my_formula, 'MyIndex')
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Band Configuration
|
|
115
|
+
|
|
116
|
+
Specify how bands are mapped in your GeoTIFF file:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
band_config = {
|
|
120
|
+
'red': 1, # Band 1 is red
|
|
121
|
+
'green': 2, # Band 2 is green
|
|
122
|
+
'blue': 3, # Band 3 is blue
|
|
123
|
+
'nir': 4, # Band 4 is NIR
|
|
124
|
+
'rededge': 5 # Band 5 is red-edge (optional, 5-band only)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
ortho = Orthomosaic('field.tif', band_config=band_config)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Vegetation Indices
|
|
131
|
+
|
|
132
|
+
10 vegetation indices are implemented:
|
|
133
|
+
|
|
134
|
+
| Index | Formula | Use Case |
|
|
135
|
+
|-------|---------|----------|
|
|
136
|
+
| NDVI | (NIR - RED) / (NIR + RED) | Vegetation health, stress detection |
|
|
137
|
+
| NDRE | (NIR - RedEdge) / (NIR + RedEdge) | Nitrogen content (5-band only) |
|
|
138
|
+
| GNDVI | (NIR - GREEN) / (NIR + GREEN) | Chlorophyll content |
|
|
139
|
+
| ExG | 2*GREEN - RED - BLUE | Greenness index for RGB imagery |
|
|
140
|
+
| SAVI | ((NIR - RED) / (NIR + RED + L)) * (1 + L) | Soil adjustment (L=0.5) |
|
|
141
|
+
| MSAVI | Modified SAVI | Improved soil adjustment |
|
|
142
|
+
| VARI | (GREEN - RED) / (GREEN + RED - BLUE) | Visible atmospherically resistant |
|
|
143
|
+
| ARVI | (NIR - (2*RED - BLUE)) / (NIR + (2*RED - BLUE)) | Atmospheric correction |
|
|
144
|
+
| CVI | (NIR / GREEN) * (RED / GREEN) | Chlorophyll |
|
|
145
|
+
| OSAVI | Optimized SAVI with Y=0.16 | Better soil adjustment |
|
|
146
|
+
|
|
147
|
+
## 3D Visualization Functions
|
|
148
|
+
|
|
149
|
+
The visualization module (3dVis) provides 5 simple functions:
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from dronelytics.visualization import (
|
|
153
|
+
show_pointcloud, # Visualize point cloud with classification
|
|
154
|
+
show_dem, # Visualize elevation models (DTM, DSM)
|
|
155
|
+
show_chm, # Visualize crop height model
|
|
156
|
+
show_mesh, # Visualize 3D surface mesh
|
|
157
|
+
show_comparison # Compare multiple elevation models
|
|
158
|
+
)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## File Structure
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
dronelytics/
|
|
165
|
+
├── core/ # Core modules
|
|
166
|
+
│ ├── orthomosaic.py # Orthomosaic loading and management
|
|
167
|
+
│ ├── indices.py # Standard vegetation indices
|
|
168
|
+
│ ├── vegetation_indices_extended.py # 10 indices + custom formulas
|
|
169
|
+
│ ├── segmentation.py # Plot boundary detection
|
|
170
|
+
│ ├── extraction.py # Pixel-level data extraction
|
|
171
|
+
│ └── pointcloud.py # Point cloud processing, DTM/DSM/CHM
|
|
172
|
+
│
|
|
173
|
+
├── visualization/ # 3D visualization (3dVis)
|
|
174
|
+
│ └── vis3d.py # 5 visualization functions
|
|
175
|
+
│
|
|
176
|
+
├── export/ # Data export
|
|
177
|
+
│ ├── csv_export.py # CSV export
|
|
178
|
+
│ └── excel_export.py # Excel export
|
|
179
|
+
│
|
|
180
|
+
├── processing/ # Analysis pipelines
|
|
181
|
+
│ └── pipeline.py # Orchestrate analysis workflow
|
|
182
|
+
│
|
|
183
|
+
├── data/ # Data structures
|
|
184
|
+
│ └── structures.py # VegetationIndexData, SegmentationResult, etc.
|
|
185
|
+
│
|
|
186
|
+
└── utils/ # Utilities
|
|
187
|
+
└── logger.py # Clean logging (no decorative symbols)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Examples
|
|
191
|
+
|
|
192
|
+
### Basic Workflow
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
python examples/basic_workflow.py
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Advanced Workflow (5-band, Point Cloud)
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
python examples/advanced_workflow.py
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 3D Visualization
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
python examples/visualization_example.py
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Requirements
|
|
211
|
+
|
|
212
|
+
- Python 3.7+
|
|
213
|
+
- numpy
|
|
214
|
+
- rasterio (GeoTIFF support)
|
|
215
|
+
- matplotlib (visualization)
|
|
216
|
+
- scipy (segmentation)
|
|
217
|
+
- pandas (data extraction)
|
|
218
|
+
|
|
219
|
+
Optional dependencies:
|
|
220
|
+
- laspy (LAS/LAZ file support)
|
|
221
|
+
- pyvista (3D mesh and interactive visualization)
|
|
222
|
+
|
|
223
|
+
## Testing
|
|
224
|
+
|
|
225
|
+
Run unit tests:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
python -m pytest tests/test_core.py
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Or use the test module directly:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
python tests/test_core.py
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## CHM Calculation
|
|
238
|
+
|
|
239
|
+
Crop Height Model (CHM) is calculated as:
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
CHM = DSM - DTM
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Where:
|
|
246
|
+
- DSM: Digital Surface Model (top of vegetation)
|
|
247
|
+
- DTM: Digital Terrain Model (ground surface)
|
|
248
|
+
- CHM: Height of vegetation above ground
|
|
249
|
+
|
|
250
|
+
## Documentation
|
|
251
|
+
|
|
252
|
+
- `WORKFLOW.md`: Complete analysis workflow guide
|
|
253
|
+
- `VISUALIZATION_GUIDE.md`: 3D visualization usage
|
|
254
|
+
- `5BAND_SUPPORT_GUIDE.md`: Red-edge band support
|
|
255
|
+
- `COMPLETE_FEATURE_SUMMARY.md`: Feature overview
|
|
256
|
+
- `DEPLOYMENT_CHECKLIST.md`: Production deployment guide
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
MIT License. See LICENSE file for details.
|
|
261
|
+
|
|
262
|
+
## Citation
|
|
263
|
+
|
|
264
|
+
If you use Dronelytics in your research, please cite:
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
Dronelytics v1.0.0 - Comprehensive drone orthomosaic analysis package
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Support
|
|
271
|
+
|
|
272
|
+
For issues, feature requests, or questions, please refer to the documentation files or create an issue on GitHub.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
Made for agricultural field phenotyping and precision agriculture research.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Dronelytics: Comprehensive package for end-to-end drone orthomosaic analysis
|
|
3
|
+
and agricultural field phenotyping.
|
|
4
|
+
|
|
5
|
+
Features:
|
|
6
|
+
- Load and process multispectral orthomosaics (4-band and 5-band)
|
|
7
|
+
- Calculate 10 vegetation indices with custom formula support
|
|
8
|
+
- Automated plot boundary detection
|
|
9
|
+
- Pixel-level data extraction
|
|
10
|
+
- 3D canopy modeling from point clouds (DTM, DSM, CHM)
|
|
11
|
+
- 3D visualization of point clouds, elevation models, and mesh surfaces
|
|
12
|
+
- CSV/Excel data export
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
__version__ = "1.0.0"
|
|
16
|
+
__author__ = "Research Development"
|
|
17
|
+
__license__ = "MIT"
|
|
18
|
+
|
|
19
|
+
from .core.orthomosaic import Orthomosaic
|
|
20
|
+
from .core.indices import VegetationIndices
|
|
21
|
+
from .core.vegetation_indices_extended import VegetationIndicesExtended
|
|
22
|
+
from .core.segmentation import PlotSegmentation
|
|
23
|
+
from .core.extraction import PixelExtraction
|
|
24
|
+
from .core.pointcloud import PointCloudProcessor
|
|
25
|
+
from .processing.pipeline import AnalysisPipeline
|
|
26
|
+
from .export.csv_export import CSVExporter
|
|
27
|
+
from .export.excel_export import ExcelExporter
|
|
28
|
+
from .utils.logger import setup_logger
|
|
29
|
+
from . import visualization
|
|
30
|
+
|
|
31
|
+
logger = setup_logger(__name__)
|
|
32
|
+
|
|
33
|
+
__all__ = [
|
|
34
|
+
'Orthomosaic',
|
|
35
|
+
'VegetationIndices',
|
|
36
|
+
'VegetationIndicesExtended',
|
|
37
|
+
'PlotSegmentation',
|
|
38
|
+
'PixelExtraction',
|
|
39
|
+
'PointCloudProcessor',
|
|
40
|
+
'AnalysisPipeline',
|
|
41
|
+
'CSVExporter',
|
|
42
|
+
'ExcelExporter',
|
|
43
|
+
'setup_logger',
|
|
44
|
+
'visualization',
|
|
45
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Core modules for dronelytics package."""
|
|
2
|
+
|
|
3
|
+
from .orthomosaic import Orthomosaic
|
|
4
|
+
from .indices import VegetationIndices
|
|
5
|
+
from .vegetation_indices_extended import VegetationIndicesExtended
|
|
6
|
+
from .segmentation import PlotSegmentation
|
|
7
|
+
from .extraction import PixelExtraction
|
|
8
|
+
from .pointcloud import PointCloudProcessor
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
'Orthomosaic',
|
|
12
|
+
'VegetationIndices',
|
|
13
|
+
'VegetationIndicesExtended',
|
|
14
|
+
'PlotSegmentation',
|
|
15
|
+
'PixelExtraction',
|
|
16
|
+
'PointCloudProcessor',
|
|
17
|
+
]
|