Skip to content

Commit

Permalink
signing urls with planetary computers module because anonymous acess …
Browse files Browse the repository at this point in the history
…to blob storage is not accepted anymore
  • Loading branch information
sebastienlanglois committed Oct 11, 2024
1 parent 0a98860 commit 4498480
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 14 additions & 0 deletions docs/notebooks/gis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,13 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also extract the surface properties for the same `gpd.GeoDataFrame` : "
]
},
{
"cell_type": "code",
"execution_count": 10,
Expand Down Expand Up @@ -972,6 +979,13 @@
"xhgis.surface_properties(gdf)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Again, for convenience, we can output the results in `xarray.Dataset` format : "
]
},
{
"cell_type": "code",
"execution_count": 11,
Expand Down
12 changes: 7 additions & 5 deletions src/xhydro/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import planetary_computer
import pystac_client
import rasterio
import rasterio.features
Expand Down Expand Up @@ -270,11 +271,9 @@ def _recursive_upstream_lookup(


def _flatten(x, dim="time"):
# FIXME: assert statements should only be found in test code
assert isinstance(x, xr.DataArray) # noqa: S101
if len(x[dim].values) > len(set(x[dim].values)):
x = x.groupby(dim).map(stackstac.mosaic)

if isinstance(x, xr.DataArray):
if len(x[dim].values) > len(set(x[dim].values)):
x = x.groupby(dim).map(stackstac.mosaic)
return x


Expand Down Expand Up @@ -324,6 +323,7 @@ def surface_properties(

catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)

search = catalog.search(
Expand Down Expand Up @@ -489,6 +489,7 @@ def land_use_classification(
"""
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)
collection = catalog.get_collection(collection)
ia = ItemAssetsExtension.ext(collection)
Expand Down Expand Up @@ -552,6 +553,7 @@ def land_use_plot(
"""
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)

collection = catalog.get_collection(collection)
Expand Down

0 comments on commit 4498480

Please sign in to comment.