Skip to content

Commit

Permalink
add functions
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharth0248 committed Oct 29, 2024
1 parent f234e54 commit ec72844
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 2 deletions.
46 changes: 46 additions & 0 deletions docs/advance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Exploring other functions from rasterio and rio-xarray packages

**Description**:

- **Input**:

- **Expected Output**:

**Code Snippet**:
```python
# Reprojection
ras1_lonlat = ras1.rio.reproject("EPSG:4326")
print(ras1_lonlat)

#Clip the raster
from shapely.geometry import box

minx, miny, maxx, maxy = -90.32, 31.33, -89.90, 31.15
bbox = box(minx, miny, maxx, maxy)
clipped = ras1_lonlat.rio.clip([bbox], crs="EPSG:4326")

#resample
from rasterio.enums import Resampling

# Resample
scale_factor = 0.75
with rasterio.open(tif_file) as src:
data = src.read(
out_shape=(
src.count,
int(src.height * scale_factor),
int(src.width * scale_factor)
),
resampling=Resampling.bilinear
)

profile = src.profile
profile.update(
width=data.shape[2],
height=data.shape[1]
)

with rasterio.open("VendorUtil_Planet/NewData/resampled_raster.tif", "w", **profile) as dst:
dst.write(data)

print("Success Resample saved")
4 changes: 2 additions & 2 deletions docs/authentication.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 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.
**Description**:

- **Input**: Planet API Key
- **Input**:
- **Expected Output**: Successful login message or an error if authentication fails.

**Code Snippet**:
Expand Down
32 changes: 32 additions & 0 deletions docs/errorreporting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Error Reporting

If you encounter any errors during testing, please follow these steps to report them:

1. **Capture the error output**: Copy the error message from the notebook.
2. **Open a GitHub issue**: Go to the GitHub repository and open a new issue. https://github.com/NASA-IMPACT/csdap-vendor-utilities/issues
3. **Provide the following details**:
- A brief description of the issue.
- The steps to reproduce the error.
- The error message or stack trace.
- Relevant PlanetScope product details (e.g., 3-band, 4-band, or 8-band).
- Any additional context or data used in the test.
4. Checking integration with rasterio and rio-xarray for
- Fill no data / Interpolate (rio-xarray)
- Reprojection (rio-xarray)
- Zonal statistics (rio-xarray)
- Clip (rio-xarray)
- Resampling (rasterio)

### Issue Template Example

```markdown
**Description**: Briefly describe the error.

**Steps to Reproduce**:
1. List the steps taken before the error occurred.

**Error Message**: Paste the error message or stack trace here.

**Data Information**: Mention the PlanetScope product and any specific bands used (e.g., 3-band, 4-band, or 8-band).

**Additional Context**: Provide any extra details that might help in debugging.
25 changes: 25 additions & 0 deletions docs/normalizedindex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Calculate Normalized Index

**Description**:

- **Input**:

- **Expected Output**:

**Code Snippet**:
```python
# Band Ratio
with PlanetScope.open(tif_file) as planet_obj:
normalized_idx = planet_obj.normalized_indices(band1_index = 0, band2_index = 3)
print(np.isnan(normalized_idx).all())

# NDVI
with PlanetScope.open(tif_file) as planet_obj:
ndvi = planet_obj.ndvi
print(np.unique(ndvi))

#EVI
with PlanetScope.open(tif_file) as planet_obj:
evi = planet_obj.evi
print(np.unique(evi))

24 changes: 24 additions & 0 deletions docs/quality.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Read Quality Flag

**Description**:

- **Input**:

- **Expected Output**:

**Code Snippet**:
### Accessing different quality masks
```python
with PlanetScope.open(tif_file) as planet_obj:
planet_obj.get_quality_mask("clear")
planet_obj.get_quality_mask("cloud")
planet_obj.get_quality_mask("snow")
planet_obj.get_quality_mask("shadow")
planet_obj.get_quality_mask("haze_light")
planet_obj.get_quality_mask("haze_heavy")
planet_obj.get_quality_mask("cloud")
planet_obj.get_quality_mask("confidence")

### Extract quality flags for a point from the data
with PlanetScope.open(tif_file) as planet_obj:
print(planet_obj.get_quality_from_point(lat=28.866933958061644, lon=-97.90677761357139))
17 changes: 17 additions & 0 deletions docs/read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Read Data

**Description**:

- **Input**:

- **Expected Output**:

**Code Snippet**:
```python
with PlanetScope.open(tif_file) as planetdat:
data_array = planetdat.data
udm_data_array = planetdat.quality_data
metadata = planetdat.metadata

print(metadata)
print(udm_data_array)
15 changes: 15 additions & 0 deletions docs/surfacereflectance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Calculate Surface Reflectance

**Description**:

- **Input**:

- **Expected Output**:

**Code Snippet**:
```python
with PlanetScope.open(tif_file) as planet_obj:
print(planet_obj.reflectance_coefficient)

with PlanetScope.open(tif_file) as planet_obj:
print(planet_obj.surface_reflectance.shape)

0 comments on commit ec72844

Please sign in to comment.