Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/developmentseed/titiler int…
Browse files Browse the repository at this point in the history
…o HEAD
  • Loading branch information
vincentsarago committed Dec 19, 2024
2 parents bc00900 + defc468 commit 35b8de5
Show file tree
Hide file tree
Showing 30 changed files with 402 additions and 414 deletions.
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@ repos:
hooks:
- id: validate-pyproject

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
language_version: python

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
language_version: python

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.238
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.11.2
hooks:
- id: mypy
language_version: python
Expand Down
86 changes: 36 additions & 50 deletions docs/src/examples/notebooks/Working_with_Algorithm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"metadata": {},
"outputs": [],
"source": [
"titiler_endpoint = \"https://titiler.xyz\" # Developmentseed Demo endpoint. Please be kind."
"titiler_endpoint = (\n",
" \"https://titiler.xyz\" # Developmentseed Demo endpoint. Please be kind.\n",
")"
]
},
{
Expand Down Expand Up @@ -70,9 +72,9 @@
"# Fetch dataset Metadata\n",
"r = httpx.get(\n",
" f\"{titiler_endpoint}/cog/info\",\n",
" params = {\n",
" params={\n",
" \"url\": url,\n",
" }\n",
" },\n",
").json()\n",
"\n",
"print(r)"
Expand All @@ -97,21 +99,19 @@
"source": [
"r = httpx.get(\n",
" f\"{titiler_endpoint}/cog/WebMercatorQuad/tilejson.json\",\n",
" params = {\n",
" params={\n",
" \"url\": url,\n",
" }\n",
" },\n",
").json()\n",
"\n",
"bounds = r[\"bounds\"]\n",
"m = Map(\n",
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"]\n",
" location=((bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"],\n",
")\n",
"\n",
"TileLayer(\n",
" tiles=r[\"tiles\"][0],\n",
" opacity=1,\n",
" attr=\"Office fédéral de topographie swisstopo\"\n",
" tiles=r[\"tiles\"][0], opacity=1, attr=\"Office fédéral de topographie swisstopo\"\n",
").add_to(m)\n",
"m"
]
Expand All @@ -127,24 +127,22 @@
"source": [
"r = httpx.get(\n",
" f\"{titiler_endpoint}/cog/WebMercatorQuad/tilejson.json\",\n",
" params = {\n",
" params={\n",
" \"url\": url,\n",
" # rio-tiler cannot rescale automatically the data when using a colormap\n",
" \"rescale\": \"1615.812,2015.09448\",\n",
" \"colormap_name\": \"terrain\",\n",
" }\n",
" },\n",
").json()\n",
"\n",
"bounds = r[\"bounds\"]\n",
"m = Map(\n",
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"]\n",
" location=((bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"],\n",
")\n",
"\n",
"aod_layer = TileLayer(\n",
" tiles=r[\"tiles\"][0],\n",
" opacity=1,\n",
" attr=\"Office fédéral de topographie swisstopo\"\n",
" tiles=r[\"tiles\"][0], opacity=1, attr=\"Office fédéral de topographie swisstopo\"\n",
")\n",
"aod_layer.add_to(m)\n",
"m"
Expand Down Expand Up @@ -200,26 +198,22 @@
"source": [
"r = httpx.get(\n",
" f\"{titiler_endpoint}/cog/WebMercatorQuad/tilejson.json\",\n",
" params = {\n",
" params={\n",
" \"url\": url,\n",
" \"algorithm\": \"hillshade\",\n",
" # Hillshade algorithm use a 3pixel buffer so we need\n",
" # to tell the tiler to apply a 3 pixel buffer around each tile\n",
" \"buffer\": 3,\n",
" }\n",
" },\n",
").json()\n",
"\n",
"bounds = r[\"bounds\"]\n",
"m = Map(\n",
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"]\n",
" location=((bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"],\n",
")\n",
"\n",
"aod_layer = TileLayer(\n",
" tiles=r[\"tiles\"][0],\n",
" opacity=1,\n",
" attr=\"Yo!!\"\n",
")\n",
"aod_layer = TileLayer(tiles=r[\"tiles\"][0], opacity=1, attr=\"Yo!!\")\n",
"aod_layer.add_to(m)\n",
"m"
]
Expand All @@ -241,31 +235,27 @@
"source": [
"r = httpx.get(\n",
" f\"{titiler_endpoint}/cog/WebMercatorQuad/tilejson.json\",\n",
" params = {\n",
" params={\n",
" \"url\": url,\n",
" \"algorithm\": \"contours\",\n",
" \"algorithm_params\": json.dumps(\n",
" {\n",
" \"increment\": 20, # contour line every 20 meters\n",
" \"thickness\": 2, # 2m thickness\n",
" \"increment\": 20, # contour line every 20 meters\n",
" \"thickness\": 2, # 2m thickness\n",
" \"minz\": 1600,\n",
" \"maxz\": 2000\n",
" \"maxz\": 2000,\n",
" }\n",
" ),\n",
" }\n",
" },\n",
").json()\n",
"\n",
"bounds = r[\"bounds\"]\n",
"m = Map(\n",
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"]\n",
" location=((bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"],\n",
")\n",
"\n",
"TileLayer(\n",
" tiles=r[\"tiles\"][0],\n",
" opacity=1,\n",
" attr=\"Yo!!\"\n",
").add_to(m)\n",
"TileLayer(tiles=r[\"tiles\"][0], opacity=1, attr=\"Yo!!\").add_to(m)\n",
"m"
]
},
Expand All @@ -278,31 +268,27 @@
"source": [
"r = httpx.get(\n",
" f\"{titiler_endpoint}/cog/WebMercatorQuad/tilejson.json\",\n",
" params = {\n",
" params={\n",
" \"url\": url,\n",
" \"algorithm\": \"contours\",\n",
" \"algorithm_params\": json.dumps(\n",
" {\n",
" \"increment\": 5, # contour line every 5 meters\n",
" \"thickness\": 1, # 1m thickness\n",
" \"increment\": 5, # contour line every 5 meters\n",
" \"thickness\": 1, # 1m thickness\n",
" \"minz\": 1600,\n",
" \"maxz\": 2000\n",
" \"maxz\": 2000,\n",
" }\n",
" ),\n",
" }\n",
" },\n",
").json()\n",
"\n",
"bounds = r[\"bounds\"]\n",
"m = Map(\n",
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"]\n",
" location=((bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2),\n",
" zoom_start=r[\"minzoom\"],\n",
")\n",
"\n",
"TileLayer(\n",
" tiles=r[\"tiles\"][0],\n",
" opacity=1,\n",
" attr=\"Yo!!\"\n",
").add_to(m)\n",
"TileLayer(tiles=r[\"tiles\"][0], opacity=1, attr=\"Yo!!\").add_to(m)\n",
"m"
]
},
Expand Down
Loading

0 comments on commit 35b8de5

Please sign in to comment.