{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/gee-community/geemap/blob/master/examples/notebooks/95_create_cog.ipynb)\n", "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/geemap-binder)\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you are using a recently implemented geemap feature that has not yet been released to PyPI or conda-forge, you can uncomment the following line to install the development version from GitHub." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# geemap.update_package()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Provide a dataset path or URL." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "url = \"https://github.com/giswqs/data/raw/main/raster/srtm90.tif\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Validate COG." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.cog_validate(url)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.cog_validate(url, verbose=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Convert the image to tiled COG." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out_cog = \"cog.tif\"\n", "geemap.image_to_cog(url, out_cog)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Validate COG." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.cog_validate(out_cog)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.cog_validate(out_cog, verbose=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add COG to map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "m.add_raster(out_cog, palette=\"dem\", layer_name=\"Local COG\")\n", "m.add_cog_layer(url, palette=\"gist_earth\", name=\"Remote COG\")\n", "m" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }