Skip to content

Commit

Permalink
Updated notebooks 2023-09-07 UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 7, 2023
1 parent db87669 commit 9963f4f
Showing 1 changed file with 161 additions and 0 deletions.
161 changes: 161 additions & 0 deletions content/notebooks/74_map_tiles_to_geotiff.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/74_map_tiles_to_geotiff.ipynb)\n",
"[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/opengeos/leafmap/blob/master/examples/notebooks/74_map_tiles_to_geotiff.ipynb)\n",
"[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/opengeos/leafmap&urlpath=lab/tree/leafmap/examples/notebooks/74_map_tiles_to_geotiff.ipynb&branch=master)\n",
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/74_map_tiles_to_geotiff.ipynb)\n",
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/opengeos/leafmap/blob/master/examples/notebooks/74_map_tiles_to_geotiff.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/leafmap-binder)\n",
"\n",
"**Downloading maps tiles and converting them to a GeoTIFF file**\n",
"\n",
"Disclaimer: The `leafmap.map_tiles_to_geotiff()` function is adapted from the [tms2geotiff](https://github.com/gumblex/tms2geotiff) repo. Credit goes to the GitHub user @gumblex."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# %pip install -U leafmap"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from leafmap import leafmap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create an interactive map."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the drawing tools to draw a rectangle on the map."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if m.user_roi is not None:\n",
" bbox = m.user_roi_bounds()\n",
"else:\n",
" bbox = [-122.5216, 37.733, -122.3661, 37.8095]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Download TMS tiles and create a GeoTIFF file. First, let's try OpenStreetMap."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"leafmap.map_tiles_to_geotiff('osm.tif', bbox, zoom=13, source='OpenStreetMap', quiet=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](https://i.imgur.com/ft597DD.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Try Google Satellite."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"leafmap.map_tiles_to_geotiff('satellite.tif', bbox, zoom=13, source='Satellite')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](https://i.imgur.com/ILYunA9.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Try OpenTopoMap."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"source = 'https://a.tile.opentopomap.org/{z}/{x}/{y}.png'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"leafmap.map_tiles_to_geotiff('topo.tif', bbox, zoom=13, source=source)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](https://i.imgur.com/4UkUZKw.png)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (Pyodide)",
"language": "python",
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 9963f4f

Please sign in to comment.