-
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
f234e54
commit ec72844
Showing
7 changed files
with
161 additions
and
2 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,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") |
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
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,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. |
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,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)) | ||
|
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,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)) |
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,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) |
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,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) |