Skip to content

Commit

Permalink
Add Cloud Optimized GeoTIFF tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Oct 11, 2020
1 parent 574039f commit e859ddd
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 20 deletions.
22 changes: 17 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ geemap
.. image:: https://joss.theoj.org/papers/91af8757c56e3fed2535fcd165137116/status.svg
:target: https://joss.theoj.org/papers/91af8757c56e3fed2535fcd165137116

Lead authors: Dr. Qiusheng Wu (https://wetlands.io)

**A Python package for interactive mapping with Google Earth Engine, ipyleaflet, and ipywidgets.**

* GitHub repo: https://github.com/giswqs/geemap
* Documentation: https://geemap.readthedocs.io
* Documentation: https://giswqs.github.io/geemap
* PyPI: https://pypi.org/project/geemap/
* Conda-forge: https://anaconda.org/conda-forge/geemap
* 360+ GEE notebook examples: https://github.com/giswqs/earthengine-py-notebooks
Expand Down Expand Up @@ -73,7 +71,7 @@ analyze and visualize Earth Engine datasets interactively within a Jupyter-based
**geemap** is intended for students and researchers, who would like to utilize the Python ecosystem of diverse libraries and tools to explore Google Earth Engine. It is also designed for existing GEE users who would like to transition from the GEE JavaScript API to Python API. The automated JavaScript-to-Python `conversion module <https://github.com/giswqs/geemap/blob/master/geemap/conversion.py>`__ of the **geemap** package
can greatly reduce the time needed to convert existing GEE JavaScripts to Python scripts and Jupyter notebooks.

For video tutorials and notebook examples, please visit `<https://github.com/giswqs/geemap/tree/master/examples>`__. For complete documentation on geemap modules and methods, please visit `<https://geemap.readthedocs.io/en/latest/source/geemap.html>`_.
For video tutorials and notebook examples, please visit `<https://github.com/giswqs/geemap/tree/master/examples>`__. For complete documentation on geemap modules and methods, please visit `<https://giswqs.github.io/geemap/geemap>`_.

If you find geemap useful in your research, please consider citing the following papers to support my work. Thank you for your support.

Expand Down Expand Up @@ -175,7 +173,7 @@ To install the development version from GitHub directly within Jupyter notebook
geemap.update_package()
To use geemap in a Docker container, check out this `page <https://hub.docker.com/r/bkavlak/geemap>`__.
To use geemap in a Docker container, check out `ee-jupyter-contrib <https://github.com/gee-community/ee-jupyter-contrib/tree/master/docker/gcp_ai_deep_learning_platform>`__ or this `page <https://hub.docker.com/r/bkavlak/geemap>`__.


Usage
Expand Down Expand Up @@ -471,6 +469,20 @@ To extract pixel values based on user-drawn geometries:
geemap.extract_values_to_points(out_shp)
To load a Cloud Optimized GeoTIFF as an ee.Image:

.. code:: python
image = geemap.load_GeoTIFF(URL)
To load a list of Cloud Optimized GeoTIFFs as an ee.ImageCollection:

.. code:: python
collection = geemap.load_GeoTIFFs(URLs)
Examples
--------

Expand Down
3 changes: 2 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![image](https://img.shields.io/pypi/v/geemap.svg)](https://pypi.python.org/pypi/geemap)
[![image](https://img.shields.io/conda/vn/conda-forge/geemap.svg)](https://anaconda.org/conda-forge/geemap)
[![image](https://pepy.tech/badge/geemap)](https://pepy.tech/project/geemap)
[![image](https://readthedocs.org/projects/geemap/badge/?version=latest)](https://geemap.readthedocs.io/en/latest/?badge=latest)
[![image](https://readthedocs.org/projects/geemap/badge/?version=latest)](https://giswqs.github.io/geemap/geemap)
[![image](https://img.shields.io/badge/YouTube-GEE%20Tutorials-red)](https://gishub.org/geemap)
[![image](https://img.shields.io/twitter/follow/giswqs?style=social)](https://twitter.com/giswqs)
[![image](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -56,6 +56,7 @@ More video tutorials for geemap and Earth Engine are available on my [YouTube ch
35. How to use geemap and Earth Engine in Google Colab ([video](https://youtu.be/fG6kx9vq7hs) | [gif](https://i.imgur.com/OJCasMe.gif) | [notebook](https://github.com/giswqs/geemap/blob/master/examples/notebooks/35_geemap_colab.ipynb))
36. How to find out the greenest day of the year ([video](https://youtu.be/9KEaW4Ks5fQ) | [gif](https://i.imgur.com/eLDeb4t.gif) | [notebook](https://github.com/giswqs/geemap/blob/master/examples/notebooks/36_quality_mosaic.ipynb))
37. How to use Earth Engine with pydeck for 3D terrain visualization ([video](https://youtu.be/4E3zOP3-md8) | [gif](https://i.imgur.com/Gx7Y015.gif) | [notebook](https://github.com/giswqs/geemap/blob/master/examples/notebooks/37_pydeck_3d.ipynb))
38. How to use Cloud Optimized GeoTIFF with Earth Engine (video | gif | [notebook](https://github.com/giswqs/geemap/blob/master/examples/notebooks/38_cloud_geotiff))


### 1. Introducing the geemap Python package for interactive mapping with Google Earth Engine
Expand Down
243 changes: 243 additions & 0 deletions examples/notebooks/38_cloud_geotiff.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to use Cloud Optimized GeoTIFF with Earth Engine \n",
"\n",
"A Cloud Optimized GeoTIFF (COG) is a regular GeoTIFF file, aimed at being hosted on a HTTP file server, with an internal organization that enables more efficient workflows on the cloud. It does this by leveraging the ability of clients issuing HTTP GET range requests to ask for just the parts of a file they need. \n",
"\n",
"More information about COG can be found at <https://www.cogeo.org/in-depth.html>\n",
"\n",
"Some publicly available Cloud Optimized GeoTIFFs:\n",
"\n",
"* https://stacindex.org/\n",
"* https://cloud.google.com/storage/docs/public-datasets/landsat"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading a Cloud Optimized GeoTIFF as an ee.Image\n",
"\n",
"Note that only Cloud Optimized GeoTIFF hosted on Google Cloud Storage is supported. Other cloud storage providers (e.g., AWS) are not supported.\n",
"\n",
"In this example, we are going to use the [Planet Disaster Data](https://stacindex.org/catalogs/planet-disaster-data#/?t=catalogs)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ee\n",
"import geemap"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Map = geemap.Map()\n",
"Map"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"URL = 'https://storage.googleapis.com/pdd-stac/disasters/hurricane-harvey/0831/20170831_172754_101c_3B_AnalyticMS.tif'\n",
"# URL = 'gs://pdd-stac/disasters/hurricane-harvey/0831/20170831_172754_101c_3B_AnalyticMS.tif'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"image = geemap.load_GeoTIFF(URL)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"vis = {\n",
" \"bands\":[\"B3\",\"B2\",\"B1\"],\n",
" \"min\":3000,\n",
" \"max\":13500\n",
"}\n",
"\n",
"Map.addLayer(image, vis, 'Cloud Image')\n",
"Map.centerObject(image.geometry(), 12)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading a list of Cloud Optimized GeoTIFFs as an ee.ImageCollection\n",
"\n",
"In this example, we are going to use the Landsat data hosted on Google Cloud. \n",
"\n",
"https://cloud.google.com/storage/docs/public-datasets/landsat\n",
"\n",
"https://console.cloud.google.com/storage/browser/gcp-public-data-landsat/LC08/01/044/034/LC08_L1TP_044034_20131228_20170307_01_T1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Map = geemap.Map()\n",
"Map"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"B3 = 'gs://gcp-public-data-landsat/LC08/01/044/034/LC08_L1TP_044034_20131228_20170307_01_T1/LC08_L1TP_044034_20131228_20170307_01_T1_B3.TIF'\n",
"B4 = 'gs://gcp-public-data-landsat/LC08/01/044/034/LC08_L1TP_044034_20131228_20170307_01_T1/LC08_L1TP_044034_20131228_20170307_01_T1_B4.TIF'\n",
"B5 = 'gs://gcp-public-data-landsat/LC08/01/044/034/LC08_L1TP_044034_20131228_20170307_01_T1/LC08_L1TP_044034_20131228_20170307_01_T1_B5.TIF'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"URLs = [B3, B4, B5]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"collection = geemap.load_GeoTIFFs(URLs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"image = collection.toBands().rename(['Green', 'Red', 'NIR']).selfMask()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"vis = {\n",
" 'bands': ['NIR', 'Red', 'Green'],\n",
" 'min': 100,\n",
" 'max': 12000,\n",
" 'gamma': 0.8\n",
"}\n",
"\n",
"Map.addLayer(image, vis, 'Image')\n",
"Map.centerObject(image.geometry(), 8)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ndvi = image.normalizedDifference(['NIR', 'Red'])\n",
"ndvi_vis = {\n",
" 'min': 0, \n",
" 'max': 1, \n",
" 'palette': ['blue', 'green']\n",
"}\n",
"Map.addLayer(ndvi, {}, 'NDVI')"
]
}
],
"metadata": {
"hide_input": false,
"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.8.2"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Table of Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit e859ddd

Please sign in to comment.