diff --git a/content/notebooks/74_map_tiles_to_geotiff.ipynb b/content/notebooks/74_map_tiles_to_geotiff.ipynb new file mode 100644 index 0000000..28b773f --- /dev/null +++ b/content/notebooks/74_map_tiles_to_geotiff.ipynb @@ -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 +}