diff --git a/docs/authentication.md b/docs/authentication.md new file mode 100644 index 0000000..2d3817f --- /dev/null +++ b/docs/authentication.md @@ -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!") diff --git a/docs/download.md b/docs/download.md new file mode 100644 index 0000000..0fe5a69 --- /dev/null +++ b/docs/download.md @@ -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) diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..8c5a3a7 --- /dev/null +++ b/docs/index.md @@ -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) diff --git a/docs/search_filter.md b/docs/search_filter.md new file mode 100644 index 0000000..ffbba24 --- /dev/null +++ b/docs/search_filter.md @@ -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)) diff --git a/docs/transformation.md b/docs/transformation.md new file mode 100644 index 0000000..ba35215 --- /dev/null +++ b/docs/transformation.md @@ -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!")