Giter Site home page Giter Site logo

alexfang0214sh / geemap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gee-community/geemap

0.0 1.0 0.0 196 KB

A Python package for interactive mapping using Google Earth Engine, ipyleaflet, and ipywidgets

Home Page: https://geemap.readthedocs.io/

License: MIT License

Makefile 2.66% Python 82.63% Jupyter Notebook 7.36% JavaScript 7.35%

geemap's Introduction

geemap

https://pepy.tech/badge/geemap https://readthedocs.org/projects/geemap/badge/?version=latest

Authors: Dr. Qiusheng Wu (https://wetlands.io)

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

Contents

Features

  • Automatically converts Earth Engine JavaScripts to Python scripts and Jupyter Notebooks.
  • Adds Earth Engine tile layers to ipyleaflet map for interactive mapping.
  • Supports Earth Engine JavaScript API functions in Python, such as Map.AddLayer(), Map.setCenter(), Map.centerObject(), Map.setOptions().
  • Captures user inputs and query Earth Engine objects.
  • Plots charts based on Earth Engine data.

Installation

To install geemap , run this command in your terminal:

pip install geemap

If you have Anaconda or Miniconda installed on your computer, you can use create conda Python environment to install geemap:

conda create -n gee python
conda activate gee
pip install geemap

If you have installed geemap before and want to upgrade to the latest version, you can use the following command:

pip install geemap -

To install the development version from GitHub, run this command in your terminal:

pip install git+https://github.com/giswqs/geemap

Examples

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

Converting GEE JavaScripts to Python scripts and Jupyter notebooks

Launch an interactive notebook with Google Colab, mybinder.org, or binder.pangeo.io. 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.

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)

https://i.imgur.com/8bedWtl.gif

Interactive mapping using GEE Python API and geemap

Launch an interactive notebook with mybinder.org or binder.pangeo.io. Note that Google Colab currently does not support ipyleaflet. Therefore, geemap won't be able to display interactive maps on Google Colab.

import ee
import geemap
import ipyleaflet

try:
        ee.Initialize()
except Exception as e:
        ee.Authenticate()
        ee.Initialize()

# Create an interactive map
Map = ipyleaflet.Map(center=(40, -100), zoom=4, scroll_wheel_zoom=True)
Map.setOptions('HYBRID') # Add Google Satellite basemap
Map

# Add Earth Engine dataset
image = ee.Image('USGS/SRTMGL1_003')

# Set visualization parameters.
vis_params = {
        'min': 0,
        'max': 4000,
        'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']
}

# Print the elevation of Mount Everest.
xy = ee.Geometry.Point([86.9250, 27.9881])
elev = image.sample(xy, 30).first().get('elevation').getInfo()
print('Mount Everest elevation (m):', elev)

# Add Earth Engine layers to Map
Map.addLayer(image, vis_params, 'STRM DEM', True, 0.5)
Map.addLayer(xy, {'color': 'red'}, 'Mount Everest')

# Set center of the map
Map.centerObject(ee_object=xy, zoom=13)
Map.setCenter(lon=-100, lat=40, zoom=4)

https://i.imgur.com/7NMQw6I.gif

Dependencies

Reporting Bugs

Report bugs at https://github.com/giswqs/geemap/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

geemap's People

Contributors

giswqs avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.