Earthengine-py-notebooks - A collection of 360+ Jupyter Python notebook examples for using Google Earth Engine with interactive mapping

Overview

earthengine-py-notebooks

image image image image image image image image Twitter Follow

A collection of 360+ Jupyter Python notebook examples for using Google Earth Engine with interactive mapping

Contact: Qiusheng Wu (https://wetlands.io)

1. Description

This repository is a collection of 360+ Jupyter Python notebook examples. I developed these examples by converting my other repo qgis-earthengine-examples from Python scripts to Jupyter notebooks. Now you can display Earth Engine data layers interactively in Jupyter notebooks without having to install QGIS. Several Python packages are being used in these examples, including the Earth Engine Python API, folium, ipyleaflet, and geemap. The geemap Python package is built upon the folium and ipyleaflet packages and implements several methods for interacting with Earth Engine data layers, such as Map.addLayer(), Map.setCenter(), Map.centerObject(), and Map.setOptions().

2. Usage

  • Step 1: Explore this repository and open any available Jupyter notebook in your browser (e.g., template.ipynb)
  • Step 2: When the selected Jupyter notebook is open, click the Notebook Viewer link to view the interactive map.
  • Step 3: If you would like to execute cells in the notebook interactively, you will need to Sign up for a Google Earth Engine account. Then you can click either Run in Google Colab to execute code interactively. This will allow you to add your own Earth Engine Python script.

3. How to automatically convert Earth Engine JavaScripts to Python scripts?

The following examples require the geemap package, which can be installed using pip install geemap. Check the Installation section for more information.

Launch an interactive notebook with Google Colab. Keep in mind that the conversion might not always work perfectly. Additional manual changes might still be needed. ui and chart are not supported. The source code for this automated conversion module can be found at conversion.py.

image

import os
from geemap.conversion import *

# Create a temporary working directory
work_dir = os.path.join(os.path.expanduser('~'), 'geemap')
# Get Earth Engine JavaScript examples. There are five examples in the geemap package folder. 
# Change js_dir to your own folder containing your Earth Engine JavaScripts, such as js_dir = '/path/to/your/js/folder'
js_dir = get_js_examples(out_dir=work_dir) 

# Convert all Earth Engine JavaScripts in a folder recursively to Python scripts.
js_to_python_dir(in_dir=js_dir, out_dir=js_dir, use_qgis=True)
print("Python scripts saved at: {}".format(js_dir))

# Convert all Earth Engine Python scripts in a folder recursively to Jupyter notebooks.
nb_template = get_nb_template()  # Get the notebook template from the package folder.
py_to_ipynb_dir(js_dir, nb_template)

# Execute all Jupyter notebooks in a folder recursively and save the output cells.
execute_notebook_dir(in_dir=js_dir)

image

4. Demo

ee-py-notebooks

5. Examples

The Table of Contents below mimics the structure of the Google Earth Engine API Documentation. I strongly encourage you to check out the API Documentation if you need an in-depth explanation of each Python example. Please note that the list below does not include all the Python examples contained in this repository. You are welcome to explore the repository and find more examples to suit your needs.

Get Started

Machine Learning

Image

ImageCollection

Geometry, Feature, FeatureCollection

Reducer

Join

Array

Specialized Algorithms

Asset Management

How Earth Engine Works

Filter

Visualization

Datasets

Tutorials

Gena's Examples

Comments
  • Downloading Large Images Mosaic from GEE

    Downloading Large Images Mosaic from GEE

    Hi Professor, I hope you are doing good . I was creating a mosaic for larger area from sentinel 2 collection . Isn't there a way to download those images by chipping into smaller ones ? There is a limit of 1gb but I was trying to download whole cloud free mosaic .

    Thank you for your help !

    opened by MrZombie69232 3
  • Export landset image...

    Export landset image...

    Hello, professor,

    I want to use your GEEMAP library to export pictures. There are 300 examples in your tutorial. I am a bit confused and I don’t know how to use Google Earth.

    Can you give some suggestions based on the picture I gave and which examples should I use?

    There are two key points:

    1. Add label of localtion, like A in the pic.
    2. Display the image acquisition time.

    Thank you very much. 20211122113953

    Another question: I use this script in jupyterlab, there are some error..

    image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_038029_20180810')
    
    landsat_vis = {
        'bands': ['B4', 'B3', 'B2'], 
        'gamma': 1.4
    }
    Map.addLayer(image, landsat_vis, "LE7_TOA_5YEAR/1999_2003", True, 0.7)
    # Draw any shapes on the map using the Drawing tools before executing this code block
    feature = Map.draw_last_feature
    
    if feature is None:
        geom = ee.Geometry.Polygon([[[-115.413031, 35.889467],
        [-115.413031, 36.543157],
        [-114.034328, 36.543157],
        [-114.034328, 35.889467],
        [-115.413031, 35.889467]]])
        feature = ee.Feature(geom, {})
    
    roi = feature.geometry()
    import os
    out_dir = os.path.join('/root/Downloads')
    filename = os.path.join(out_dir, 'landsat.tif')
    geemap.ee_export_image(image, filename=filename, scale=90, region=roi, file_per_band=True)
    

    Error like this:

    Generating URL ...
    An error occurred while downloading.
    Total request size (42441000 bytes) must be less than or equal to 33554432 bytes.
    
    opened by lovechang1986 1
  • Scripts in

    Scripts in "HowEarthEngineWorks" seem to be template

    Noticed that the scripts in /HowEarthEngineWorks don't have what (I assume) is meant to be the meat of the content. Maybe I'm missing something obvious?

    opened by TimNagle-McNaughton 1
  • Can i open a image from gee and change to matrix in jupyter

    Can i open a image from gee and change to matrix in jupyter

    I performed below: ds = gdal.Open('COPERNICUS/S2_SR20170328T083601_20170328T084228_T35RNK.tif') myarray = np.array(ds.GetRasterBand(1).ReadAsArray()) But fails to open it.

    Is there other way to achieved my purpose.

    opened by xiaoxiaokuishu 1
  • Classifier notebooks use old notation

    Classifier notebooks use old notation

    Machine learning notebooks use the old classifier names.

    Here are the update ones --> https://groups.google.com/g/google-earthengine-announce/c/rCu4FP_Cn08/m/DqC192X9BAAJ

    In any case, I was not able to display the results after using the new classifiers.

    opened by RamiroMF 1
Owner
Qiusheng Wu
Assistant Professor of Geography at the University of Tennessee, Knoxville
Qiusheng Wu
A python package that extends Google Earth Engine.

A python package that extends Google Earth Engine GitHub: https://github.com/davemlz/eemont Documentation: https://eemont.readthedocs.io/ PyPI: https:

David Montero Loaiza 307 Jan 1, 2023
A ninja python package that unifies the Google Earth Engine ecosystem.

A Python package that unifies the Google Earth Engine ecosystem. EarthEngine.jl | rgee | rgee+ | eemont GitHub: https://github.com/r-earthengine/ee_ex

null 47 Dec 27, 2022
Simple CLI for Google Earth Engine Uploads

geeup: Simple CLI for Earth Engine Uploads with Selenium Support This tool came of the simple need to handle batch uploads of both image assets to col

Samapriya Roy 79 Nov 26, 2022
Get Landsat surface reflectance time-series from google earth engine

geextract Google Earth Engine data extraction tool. Quickly obtain Landsat multispectral time-series for exploratory analysis and algorithm testing On

Loïc Dutrieux 50 Dec 15, 2022
Enable geospatial data mining through Google Earth Engine in Grasshopper 3D, via its most recent Hops component.

AALU_Geo Mining This repository is produced for a masterclass at the Architectural Association Landscape Urbanism programme. Requirements Rhinoceros (

null 4 Nov 16, 2022
Google maps for Jupyter notebooks

gmaps gmaps is a plugin for including interactive Google maps in the IPython Notebook. Let's plot a heatmap of taxi pickups in San Francisco: import g

Pascal Bugnion 747 Dec 19, 2022
Digital Earth Australia notebooks and tools repository

Repository for Digital Earth Australia Jupyter Notebooks: tools and workflows for geospatial analysis with Open Data Cube and xarray

Geoscience Australia 335 Dec 24, 2022
A Python interface between Earth Engine and xarray

eexarray A Python interface between Earth Engine and xarray Description eexarray was built to make processing gridded, mesoscale time series data quic

Aaron Zuspan 159 Dec 23, 2022
Use Mapbox GL JS to visualize data in a Python Jupyter notebook

Location Data Visualization library for Jupyter Notebooks Library documentation at https://mapbox-mapboxgl-jupyter.readthedocs-hosted.com/en/latest/.

Mapbox 620 Dec 15, 2022
Python package for earth-observing satellite data processing

Satpy The Satpy package is a python library for reading and manipulating meteorological remote sensing data and writing it to various image and data f

PyTroll 882 Dec 27, 2022
A toolbox for processing earth observation data with Python.

eo-box eobox is a Python package with a small collection of tools for working with Remote Sensing / Earth Observation data. Package Overview So far, t

null 13 Jan 6, 2022
A simple python script that, given a location and a date, uses the Nasa Earth API to show a photo taken by the Landsat 8 satellite. The script must be executed on the command-line.

What does it do? Given a location and a date, it uses the Nasa Earth API to show a photo taken by the Landsat 8 satellite. The script must be executed

Caio 42 Nov 26, 2022
Open Data Cube analyses continental scale Earth Observation data through time

Open Data Cube Core Overview The Open Data Cube Core provides an integrated gridded data analysis environment for decades of analysis ready earth obse

Open Data Cube 410 Dec 13, 2022
Calculate & view the trajectory and live position of any earth-orbiting satellite

satellite-visualization A cross-platform application to calculate & view the trajectory and live position of any earth-orbiting satellite in 3D. This

Space Technology and Astronomy Cell - Open Source Society 3 Jan 8, 2022
ESMAC diags - Earth System Model Aerosol-Cloud Diagnostics Package

Earth System Model Aerosol-Cloud Diagnostics Package This Earth System Model (ES

Pacific Northwest National Laboratory 1 Jan 4, 2022
Daily social mapping project in November 2021. Maps made using PyGMT whenever possible.

Daily social mapping project in November 2021. Maps made using PyGMT whenever possible.

Wei Ji 20 Nov 24, 2022
Example of animated maps in matplotlib + geopandas using entire time series of congressional district maps from UCLA archive. rendered, interactive version below

Example of animated maps in matplotlib + geopandas using entire time series of congressional district maps from UCLA archive. rendered, interactive version below

Apoorva Lal 5 May 18, 2022
A Jupyter - Leaflet.js bridge

ipyleaflet A Jupyter / Leaflet bridge enabling interactive maps in the Jupyter notebook. Usage Selecting a basemap for a leaflet map: Loading a geojso

Jupyter Widgets 1.3k Dec 27, 2022
Interactive Maps with Geopandas

Create Interactive maps ??️ with your geodataframe Geopatra extends geopandas for interactive mapping and attempts to wrap the goodness of amazing map

sangarshanan 46 Aug 16, 2022