-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a64beb
commit f234e54
Showing
5 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Authentication | ||
|
||
**Description**: Before accessing data from the Planet API, authenticate using your API key. This step is essential for verifying permissions to access Planet’s datasets. | ||
|
||
- **Input**: Planet API Key | ||
- **Expected Output**: Successful login message or an error if authentication fails. | ||
|
||
**Code Snippet**: | ||
```python | ||
import os | ||
from planet import Auth | ||
|
||
# Authenticate with Planet API key | ||
api_key = os.getenv("PL_API_KEY") | ||
auth = Auth.from_key(api_key) | ||
print("Authenticated successfully!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
### `docs/download.md` | ||
|
||
```markdown | ||
# Download Data | ||
|
||
**Description**: Download satellite images based on the filtered search results. Each image is available in a format suitable for geospatial analysis (e.g., TIFF). | ||
|
||
- **Input**: Image product IDs from the filtered search | ||
- **Expected Output**: TIFF files of the selected satellite images | ||
|
||
**Code Snippet**: | ||
```python | ||
# Select an item from the search results | ||
item_id = results[0]["id"] | ||
product_type = "analytic" | ||
|
||
# Download the selected item | ||
client.download(item_id, product_type, output_dir="downloaded_images") | ||
print("Download completed for:", item_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Planet Data API Guide | ||
|
||
This documentation guides users through interacting with the Planet API to access, filter, download, and transform satellite imagery data. | ||
|
||
## Sections | ||
1. [Authentication](authentication.md) | ||
2. [Search and Filter Data](search_filter.md) | ||
3. [Download Data](download.md) | ||
4. [Data Transformation](transformation.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Search and Filter Data | ||
|
||
**Description**: Use search parameters to filter available Planet data based on location, time frame, and specific requirements such as cloud cover percentage. This step helps select data efficiently based on specific analysis needs. | ||
|
||
- **Input**: Bounding box coordinates, date range, maximum cloud cover percentage | ||
- **Expected Output**: List of available imagery items matching the criteria | ||
|
||
**Code Snippet**: | ||
```python | ||
from planet import DataClient, filters | ||
|
||
# Define bounding box, date range, and cloud cover filter | ||
bbox = [-122.5, 37.5, -121.5, 38.5] | ||
date_range = filters.date_range("acquired", gt="2022-01-01", lt="2022-01-31") | ||
cloud_cover = filters.range_filter("cloud_cover", lt=0.1) | ||
|
||
# Combine filters | ||
combined_filter = filters.and_filter( | ||
filters.geom_filter(bbox), | ||
date_range, | ||
cloud_cover | ||
) | ||
|
||
# Initiate DataClient and search | ||
client = DataClient(auth) | ||
results = client.search(name="PSScene3Band", filter=combined_filter) | ||
|
||
print("Number of images found:", len(results)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
### `docs/transformation.md` | ||
|
||
```markdown | ||
# Data Transformation | ||
|
||
**Description**: Transform the downloaded images as required, including reprojection, clipping, and converting data formats to meet specific project needs. | ||
|
||
- **Input**: Downloaded TIFF file, target CRS, bounding box for clipping | ||
- **Expected Output**: Geospatial data transformed to the target CRS or clipped to a specified area | ||
|
||
**Code Snippet**: | ||
```python | ||
import rasterio | ||
from rasterio.warp import calculate_default_transform, reproject, Resampling | ||
|
||
# Open the TIFF file and set target CRS | ||
with rasterio.open("downloaded_images/image.tif") as src: | ||
transform, width, height = calculate_default_transform( | ||
src.crs, 'EPSG:4326', src.width, src.height, *src.bounds | ||
) | ||
kwargs = src.meta.copy() | ||
kwargs.update({ | ||
'crs': 'EPSG:4326', | ||
'transform': transform, | ||
'width': width, | ||
'height': height | ||
}) | ||
|
||
# Reproject and save the output | ||
with rasterio.open("reprojected_image.tif", 'w', **kwargs) as dst: | ||
for i in range(1, src.count + 1): | ||
reproject( | ||
source=rasterio.band(src, i), | ||
destination=rasterio.band(dst, i), | ||
src_transform=src.transform, | ||
src_crs=src.crs, | ||
dst_transform=transform, | ||
dst_crs='EPSG:4326', | ||
resampling=Resampling.nearest | ||
) | ||
print("Reprojection completed!") |