GithubHelp home page GithubHelp logo

vwmaus / gee_subset Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bluegreen-labs/gee_subset

0.0 1.0 0.0 129 KB

Google Earth Engine subset script & library

Home Page: https://khufkens.github.io/gee_subset/

License: GNU Affero General Public License v3.0

Python 100.00%

gee_subset's Introduction

DOI

Google Earth Engine subset script & library

This is a small python script to subset GEE gridded data products into time series for a given location or list of locations. This script should make it easier to subset remote sensing time series for processing external to GEE. If this code made your life easier please refer to it using the Zenodo citation and DOI (see below / medallion) in any research papers.

Installation

Make sure you have a working Google Earth Engine python API setup. The installation instructions can be found on the GEE developer site.

After this you can either install by cloning the repository:

git clone https://github.com/khufkens/google_earth_engine_subsets.git

or, when integrating the script in other python code by using pypi:

pip install gee_subset

Use

command line

Below you find an example call to the scrip which downloads MODIS MYD09Q1 (-p, --product) reflectance data for bands 1 and 2 (-b, --band) for a number of sites as listed in selected_sites.csv and saves the results on the users desktop (-d, --directory).

./gee_subset.py -p "MODIS/MYD09Q1" \
                -b "sur_refl_b01" "sur_refl_b02" \
                -f "~/Desktop/selected_sites.csv" \
                -d "/Users/foo/Desktop/"
# prints output to console
./gee_subset.py -p "LANDSAT/LC08/C01/T1" \
                -b "B1" "B2" \
                -s "2015-01-01" \
                -e "2015-12-31" \
                -l 44.064665 -71.287575

Sites can be listed as a latitude longitude tuple using the -loc parameter, or by providing the before mentioned csv file (-f, --file parameter). Either one should be provided.

The csv file is a comma delimited file of the format:

site, latitude, longitude.

A padding value can be provided (-pd, --pad) so one can download a rectangular window of data padded x km in either direction around a particular location. This option is limited by the maximum pixels which GEE can export. For normal use (i.e. 1 to 2 km padding) this should not present a problem for most products.

General help can be queried by calling:

./gee_subset.py -h

python module

In addition the script can be loaded as a library in a python script module by calling:

import gee_subset

# or for the module itself
from gee_subset import gee_subset

The function is called gee_subset(). Consult the script for correct parameter naming conventions. Currently minimum error trapping is provided.

When using the python module remember that the module does not support lazy loading of dependencies. You will need the start your code with:

# load required modules
import os, re
import pandas as pd
import ee
from gee_subset import gee_subset

# Initialize earth engine
ee.Initialize()

# your call
gee_subset( ... )

Data format

The output of the script is tidy data in which each row is an observation. Multiple observations can be returned in case a padding value is specified. Multiple bands can be called at once by providing multiple valid bands as an argument. Multiple bands will be returned as columns in the tidy data format. When datasets overlap, such as is the case of sidelapped tiles in Landsat 8 data multiple values are returned for a given location or date. In this case the id column will inform you on the source of the data.

Demo code

An example query, calling the python script from R, downloads two years (~100 data points) of Landsat 8 Tier 1 data for two bands (red, NIR) in ~8 seconds flat. Querying for a larger footprint (1x1 km footprint) only creates a small overhead (13 sec. query). The resulting figure for the point location with the derived NDVI values is shown below. The demo script to recreate this figure is included in the examples folder of the github repository.

References

Hufkens K. (2017) A Google Earth Engine time series subset script & library. DOI: 10.5281/zenodo.833789.

gee_subset's People

Contributors

khufkens 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.