forked from opengeos/leafmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change tms_to_geotiff to map_tiles_to_geotiff (opengeos#536)
- Loading branch information
Showing
9 changed files
with
533 additions
and
332 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
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,261 @@ | ||
{ | ||
"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://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.\n", | ||
"\n", | ||
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# %pip install -U leafmap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from leafmap import leafmap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Create an interactive map." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "64179897fd044c98a924b5fc03c04dc7", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"Map(center=[20, 0], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoom_out_text…" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"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": 4, | ||
"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": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Downloaded image 1/15\n", | ||
"Downloaded image 2/15\n", | ||
"Downloaded image 3/15\n", | ||
"Downloaded image 4/15\n", | ||
"Downloaded image 5/15\n", | ||
"Downloaded image 6/15\n", | ||
"Downloaded image 7/15\n", | ||
"Downloaded image 8/15\n", | ||
"Downloaded image 9/15\n", | ||
"Downloaded image 10/15\n", | ||
"Downloaded image 11/15\n", | ||
"Downloaded image 12/15\n", | ||
"Downloaded image 13/15\n", | ||
"Downloaded image 14/15\n", | ||
"Downloaded image 15/15\n", | ||
"Saving GeoTIFF. Please wait...\n", | ||
"Image saved to osm.tif\n" | ||
] | ||
} | ||
], | ||
"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": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Downloaded image 1/15\n", | ||
"Downloaded image 2/15\n", | ||
"Downloaded image 3/15\n", | ||
"Downloaded image 4/15\n", | ||
"Downloaded image 5/15\n", | ||
"Downloaded image 6/15\n", | ||
"Downloaded image 7/15\n", | ||
"Downloaded image 8/15\n", | ||
"Downloaded image 9/15\n", | ||
"Downloaded image 10/15\n", | ||
"Downloaded image 11/15\n", | ||
"Downloaded image 12/15\n", | ||
"Downloaded image 13/15\n", | ||
"Downloaded image 14/15\n", | ||
"Downloaded image 15/15\n", | ||
"Saving GeoTIFF. Please wait...\n", | ||
"Image saved to satellite.tif\n" | ||
] | ||
} | ||
], | ||
"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": 7, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"source = 'https://a.tile.opentopomap.org/{z}/{x}/{y}.png'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Downloaded image 1/15\n", | ||
"Downloaded image 2/15\n", | ||
"Downloaded image 3/15\n", | ||
"Downloaded image 4/15\n", | ||
"Downloaded image 5/15\n", | ||
"Downloaded image 6/15\n", | ||
"Downloaded image 7/15\n", | ||
"Downloaded image 8/15\n", | ||
"Downloaded image 9/15\n", | ||
"Downloaded image 10/15\n", | ||
"Downloaded image 11/15\n", | ||
"Downloaded image 12/15\n", | ||
"Downloaded image 13/15\n", | ||
"Downloaded image 14/15\n", | ||
"Downloaded image 15/15\n", | ||
"Saving GeoTIFF. Please wait...\n", | ||
"Image saved to topo.tif\n" | ||
] | ||
} | ||
], | ||
"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 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.