Skip to content

Commit 50118df

Browse files
authored
Merge pull request #4 from betolink/main
fix cli and add info to README
2 parents 6c08e93 + 45bd225 commit 50118df

File tree

13 files changed

+605
-57
lines changed

13 files changed

+605
-57
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ Thumbs.db
5858
# -----------------------------
5959
.env
6060
.env.*
61+
62+
# -----------------------------
63+
# Output directories
64+
# -----------------------------
65+
output/
66+
results/

README.md

Lines changed: 137 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# PlanetOverlap
22
Find and organize satellite images for area/time of interest (tailored for Planet Labs Imagery)
33

4-
**planet_overlap** is a scalable satellite imagery query engine for retrieving and filtering PlanetScope imagery over large areas and long time periods.
4+
**planet_overlap** is a scalable satellite imagery query engine for retrieving and filtering Planet Labs imagery (PSScene and SkySatScene) over large areas and long time periods.
55

66
It supports:
77

8+
- 🛰 **Imagery Types**: PSScene (PlanetScope) and SkySatScene
89
- 📍 Multiple Areas of Interest (AOIs)
910
- 📌 Automatic buffering of point inputs
1011
- 🗺 Automatic spatial tiling (in degrees)
@@ -29,12 +30,13 @@ You provide:
2930

3031
The system:
3132

32-
1. Connects to the Planet API
33-
2. Filters imagery by date and quality
34-
3. Automatically tiles large areas (if needed)
35-
4. Tracks progress during execution
36-
5. Logs runtime (seconds) and peak memory usage (MB)
37-
6. Saves structured output
33+
1. Connects to the Planet API with your API key
34+
2. Searches for **PSScene** and **SkySatScene** imagery
35+
3. Filters imagery by date and quality
36+
4. Automatically tiles large areas (if needed)
37+
5. Tracks progress during execution
38+
6. Logs runtime (seconds) and peak memory usage (MB)
39+
7. Saves structured results (GeoJSON and JSON files)
3840

3941

4042
---
@@ -54,18 +56,40 @@ pip install .
5456
```
5557
---
5658
## 🔑 Planet API Key
59+
60+
This tool requires a valid Planet API key to search and retrieve imagery. You can obtain an API key from the [Planet Developer Portal](https://www.planet.com/developer/).
61+
5762
Set your API key as an environment variable:
58-
#### macOS/Linux
5963

64+
#### macOS/Linux
6065

6166
```bash
6267
export PLANET_API_KEY=your_api_key_here
6368
```
6469

65-
#### Windows (PowerShell)
70+
To make this permanent, add it to your `~/.bashrc` or `~/.zshrc`:
71+
6672
```bash
73+
echo 'export PLANET_API_KEY=your_api_key_here' >> ~/.bashrc
74+
source ~/.bashrc
75+
```
76+
77+
#### Windows (PowerShell)
78+
79+
```powershell
6780
setx PLANET_API_KEY "your_api_key_here"
6881
```
82+
83+
Restart your terminal or PowerShell session to apply the changes.
84+
85+
#### Verify API Key
86+
87+
To verify your API key is set correctly:
88+
89+
```bash
90+
echo $PLANET_API_KEY # macOS/Linux
91+
echo $env:PLANET_API_KEY # PowerShell
92+
```
6993
---
7094
## 🛰 Basic Usage
7195

@@ -78,6 +102,31 @@ planet_overlap \
78102
--output-dir ./output
79103
```
80104

105+
### CLI Options
106+
107+
| Option | Description | Default |
108+
|--------|-------------|---------|
109+
| `--aoi-file` | Path to GeoJSON file containing Area of Interest | **required** |
110+
| `--start-date` | Start date in YYYY-MM-DD format | **required** |
111+
| `--end-date` | End date in YYYY-MM-DD format | **required** |
112+
| `--output-dir` | Output directory for results | **required** |
113+
| `--max-cloud` | Maximum cloud cover fraction (0.0-1.0) | `0.5` |
114+
| `--min-sun-angle` | Minimum sun angle in degrees (0.0-90.0) | `0.0` |
115+
| `--tile-size` | Spatial tile size in decimal degrees | `1.0` |
116+
| `--point-buffer` | Buffer size for point inputs in degrees | `0.001` |
117+
118+
### Example with Filters
119+
120+
```bash
121+
planet_overlap \
122+
--aoi-file colorado.geojson \
123+
--start-date 2023-01-01 \
124+
--end-date 2023-01-31 \
125+
--max-cloud 0.3 \
126+
--min-sun-angle 30 \
127+
--output-dir ./output
128+
```
129+
81130
## 📅 Date Filtering
82131

83132
Dates must be provided in ISO format:
@@ -117,6 +166,20 @@ Sun angle is measured in degrees (°) above the horizon. Lower values may produc
117166
```bash
118167
--min-sun-angle 10
119168
```
169+
170+
---
171+
## 🛰 Imagery Types
172+
173+
The tool searches for the following Planet imagery types:
174+
175+
| Type | Description | Resolution |
176+
|------|-------------|------------|
177+
| **PSScene** | PlanetScope imagery (3-band and 4-band) | ~3.7m per pixel |
178+
| **SkySatScene** | High-resolution satellite imagery | ~0.5m per pixel |
179+
180+
Both imagery types are searched simultaneously and results are combined in the output.
181+
182+
---
120183
## 🗺 Spatial Tiling
121184
Large AOIs are automatically divided into grid tiles. This can also occur for long date ranges and memory-sensitive runs. Tile size is specified in decimal degrees (°):
122185

@@ -150,6 +213,29 @@ Buffer size is specified in decimal degrees (°):
150213
```
151214
0.001° ≈ 111 meters (latitude direction)
152215

216+
---
217+
## 📂 Output Files
218+
219+
The CLI generates the following files in your output directory:
220+
221+
| File | Description |
222+
|------|-------------|
223+
| `results.geojson` | GeoJSON file with filtered satellite imagery (contains geometry, timestamps, cloud cover, sun angle, etc.) |
224+
| `properties.json` | JSON file with all scene properties for further analysis |
225+
226+
Each scene in `results.geojson` includes:
227+
- `name`: Scene ID
228+
- `geometry`: Scene footprint as a polygon
229+
- `view_angle`: View angle of the scene
230+
- `acquired`: Acquisition timestamp
231+
- `cloud_cover`: Cloud cover fraction (0.0-1.0)
232+
- `sun_elevation`: Sun elevation angle
233+
- `sun_angle`: Sun angle above horizon (90° - sun_elevation)
234+
- `satellite_id`: Satellite identifier
235+
- `central_lon`/`central_lat`: Scene center coordinates
236+
- `local_times`: Local acquisition time
237+
- `max_sun_diff`: Maximum sun angle difference with overlapping scenes
238+
153239
---
154240
## 📊 Performance Tracking
155241
Each run reports:
@@ -176,12 +262,19 @@ Tests verify:
176262
* Tiling behavior
177263
* Point buffering
178264
* Filter construction
265+
* CLI argument parsing
266+
* Planet API integration
267+
268+
Run all tests with pytest:
179269
180-
Run all unit tests:
270+
```bash
271+
pytest tests/
272+
```
181273

274+
Run tests with verbose output:
182275

183276
```bash
184-
python -m unittest discover planet_overlap/tests
277+
pytest tests/ -v
185278
```
186279

187280
---
@@ -204,36 +297,50 @@ Workflow file:
204297
README.md # Project documentation
205298
pyproject.toml # Project configuration
206299
.gitignore # Files Git should ignore
207-
planet_overlap/
208-
├── cli.py
209-
├── geometry.py
210-
├── filters.py
211-
├── pagination.py
212-
├── quality.py
213-
├── analysis.py
214-
├── performance.py
215-
├── logger.py
216-
├── client.py
217-
├── io.py
218-
└── tests/
300+
src/
301+
└── planet_overlap/
302+
├── __init__.py
303+
├── cli.py # CLI interface and argument parsing
304+
├── geometry.py # AOI loading, point detection, buffering
305+
├── filters.py # Planet API filter construction
306+
├── pagination.py # Spatial and temporal tiling
307+
├── quality.py # Quality filtering functions
308+
├── analysis.py # Analysis and processing pipeline
309+
├── performance.py # Runtime and memory profiling
310+
├── logger.py # Logging configuration
311+
├── client.py # Planet API client and session management
312+
├── io.py # File I/O operations
313+
└── utils.py # Utility functions
314+
tests/
219315
├── __init__.py
220316
├── test_geometry.py # Test loading AOIs, point detection, buffering, polygons
221317
├── test_filters.py # Test single/multiple .geojson AOIs, date ranges, cloud/sun filters
222-
├── test_client.py # Test Planet API session creation, authentication, pagination
223-
├── test_io.py # Test reading/writing lists and CSV/GeoDataFrames
224-
├── test_quality.py # Test filtering by view_angle, sun_angle, cloud cover
225-
├── test_overlap.py # Test polygon intersection, area and sun angle calculations
226318
├── test_analysis.py # Test overall analysis pipeline logic, derived columns
227319
├── test_cli.py # Test CLI argument parsing, dynamic config, and default overrides
228-
├── test_utils.py # Test scene estimation, temporal tiling, and helper functions
229-
└── test_tiling.py # Test automatic spatial and temporal tiling logic
320+
├── test_geometry.py # Test geometry operations
321+
├── test_points.py # Test point handling and date tiling
322+
└── test_tiling.py # Test automatic spatial and temporal tiling logic
230323
```
231324

232325
---
233326
## ⚙ Requirements
234-
* Python ≥ 3.9
327+
* Python ≥ 3.10
235328
* requests
236329
* geopandas
237330
* shapely
238331
* tqdm
239332

333+
### Installing Dependencies
334+
335+
After cloning the repository, install the package with its dependencies:
336+
337+
```bash
338+
pip install .
339+
```
340+
341+
Or install dependencies manually:
342+
343+
```bash
344+
pip install geopandas shapely requests tqdm
345+
```
346+

colorado.geojson

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"type": "FeatureCollection",
3+
"features": [
4+
{
5+
"type": "Feature",
6+
"geometry": {
7+
"type": "Polygon",
8+
"coordinates": [[
9+
[-109.05, 37.00],
10+
[-102.05, 37.00],
11+
[-102.05, 41.00],
12+
[-109.05, 41.00],
13+
[-109.05, 37.00]
14+
]]
15+
},
16+
"properties": {
17+
"name": "Colorado"
18+
}
19+
}
20+
]
21+
}

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ dev = [
4141
Homepage = "https://github.com/BriannaLind/planet_overlap"
4242
Repository = "https://github.com/BriannaLind/planet_overlap"
4343

44+
[project.scripts]
45+
planet_overlap = "planet_overlap.cli:main"
46+
4447
[tool.setuptools]
4548
package-dir = {"" = "src"}
4649

0 commit comments

Comments
 (0)