New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalize the titiler_endpoint parameter #137
Comments
Thanks for opening this! So the primary motivation is to avoid sending large amounts of data from Azure blob storage to the devseed tititler endpoint at We can't just set For this to work, we would need some way for leafmap to know which endpoint to call when it needs to add a COG layer, STAC item layer, mosaic, etc. I see two potential options:
class TitilerEndpoint:
def url_for_stac_item(...): ...
def url_for_cog(...): ...
class PlanetaryComputerEndpoint(TititlerEndpoint):
def url_for_stac_item(...): ...
def url_for_cog(...): ... And then users would provide something like
For now, I'd recommend putting this logic in leafmap or some third-party library. cc @vincentsarago and @mmcfarland in case you're interested. |
@TomAugspurger Good suggestion. I will implement it using option 1. So the three endpoints ( titiler_endpoint="https://planetarycomputer.microsoft.com/api/data/v1" r = requests.get(
f"{titiler_endpoint}/item/{TileMatrixSetId}/tilejson.json", params=params
).json() r = requests.get(
f"{titiler_endpoint}/collection/{TileMatrixSetId}/tilejson.json", params=params
).json() r = requests.get(
f"{titiler_endpoint}/mosaic/{searchid}/{TileMatrixSetId}/tilejson.json", params=params
).json() |
@giswqs FYI we have a new home for TiTIler demo endpoint: Note: titiler.xyz, is deployed with the latest titiler 0.4.0 version, while the tiler on the planetary computer is still on |
We should have the Planetary Computer deployment updated sometime in mid January. I'm not sure how that'll affect leafmap, so we might need to sync up once we get our staging endpoint transitioned. One thing I'm not sure about is the |
@vincentsarago Thanks for the heads up. I will look into it and update leafmap accordingly. @TomAugspurger I don't think it will affect leafmap that much. I will make it compatible with both |
@TomAugspurger This feature has been implemented. You can now use one line of code ( import leafmap
m = leafmap.Map()
collection = "landsat-8-c2-l2"
items = "LC08_L2SP_047027_20201204_02_T1"
m.add_stac_layer(collection=collection, items=items, assets="SR_B5,SR_B4,SR_B3", name="Color infrared")
m.add_stac_layer(collection=collection, items=items, expression="SR_B5/SR_B4", colormap_name="greens", name="NDVI Green")
m Some relevant classes and functions: https://github.com/giswqs/leafmap/blob/16efea65acf9cc6e4e2f7d0c86883b0c3187cbc8/leafmap/common.py#L18-L19 |
@TomAugspurger I am wondering about this too. Does Planetary Computer has the |
Great, thanks @giswqs! I just gave it a quick try and things look great. Once it's released to PyPI / conda-forge I'll update the Hub to set the environment variable.
We don't implement any of the |
@TomAugspurger Sounds good. Will make a new release shortly |
@TomAugspurger leafmap v.0.7.0 is now available on PyPi. It should also be available on conda-forge within an hour. https://pypi.org/project/leafmap |
@TomAugspurger v0.7.0 is now available on conda-forge. BTW, you don't need to set the environment variable. By default, when the |
Great, thanks. I just merged microsoft/planetary-computer-hub#46 updating it for staging and will deploy that to production once our integration tests pass. |
Forgot to follow up noting that this is deployed to production now. Thanks again @giswqs! Would it be OK if I added a short example using leafmap with the Planetary Computer STAC API and tiler to our examples repository at https://github.com/microsoft/planetarycomputerexamples? This would be duplicative of https://leafmap.org/notebooks/37_planetary_computer/, but the PlanetaryComputerExamples repository is automatically cloned into the user's home directory, so it'd be convenient to have it there. As much as possible, we try to keep the examples focused on the Planetary Computer, and link heavily back to the upstream library's documentation. |
Sure, please feel free to adapt the notebook example in any way you like. You can remove the first part on general STAC not related to Planetary Computer. |
Currently, the default
titiler_endpoint
ishttps://api.cogeo.xyz/
. It would be useful to generalize thetitiler_endpoint
so that users can provide a custom endpoint. @TomAugspurgerFor example, Microsoft Planetary Computer has its own titiler endpoint at https://planetarycomputer.microsoft.com/api/data/v1/docs#/. Ideally, the
add_cog_layer()
function should be able to automatically detect if the notebook is running within Planetary Computer (e.g.,import planetary-computer
is successful) and use the custom endpoint.https://leafmap.org/leafmap/#leafmap.leafmap.Map.add_cog_layer
https://leafmap.org/leafmap/#leafmap.leafmap.Map.add_cog_mosaic
https://planetarycomputer.microsoft.com/api/data/v1
The text was updated successfully, but these errors were encountered: