Command line interface¶
ggextract comes with two Command Line Interfaces for convenience. Both CLI expose the functionalities of geextract.ts_extract() function, to extract a time-series from a single pixel or a circular buffer. The gee_extract_batch command takes a text file as input in which coordinates and name of multiple locations may be written, allowing batch ordrering of data. Both CLI write the extracted data to a sqlite database.
Simple CLI for ordering a single time-series and write it to a sqlite database¶
usage: gee_extract.py [-h] -lat LAT -lon LON -b BEGIN [-e END] -db DB -site
SITE -table TABLE [-r RADIUS] -s SENSOR [-stats STATS]
[-t [TIERS [TIERS ...]]]
optional arguments:
-h, --help show this help message and exit
-lat LAT, --lat LAT center latitude in Decimal Degrees
-lon LON, --lon LON center longitude in Decimal Degrees
-b BEGIN, --begin BEGIN
Anterior time-range boundary in yyyy-mm-dd
-e END, --end END Posterior time-range boundary in yyyy-mm-dd
-db DB, --db DB Path to sqlite database. Will be created if does not
exist
-site SITE, --site SITE
Label associated with that location (e.g. Site name)
-table TABLE, --table TABLE
Database table name to write data. Existing tables
will be appended
-r RADIUS, --radius RADIUS
Optional circular radius in meters around center point
-s SENSOR, --sensor SENSOR
Landsat sensor to query; one of LT4, LT5, LE7, LC8
-stats STATS, --stats STATS
Spatial aggregation function, one of mean (default),
median, max or min. Only relevant if a radius value is
provided
-t [TIERS [TIERS ...]], --tiers [TIERS [TIERS ...]]
Tiers to order (T1: highest quality, defaults to T1
and T2)
Command line utility to extract Lansat surface reflectance data from the google earth
engine platform and write the output to a local sqlite database. Query can be done for
a single pixel, or for a circular region, in which case data are spatially aggregated
for each time step using the a user defined spatial aggregation function.
sqlite tables get appended if new data are queried (i.e. for the same location but a different sensor).
--------------------------
Example usage
--------------------------
# Extract all the LT5 bands for a location in Yucatan for the entire Landsat period, with a 500m radius
gee_extract.py -s LT5 -b 1980-01-01 -lon -89.8107 -lat 20.4159 -r 500 -db /tmp/gee_db.sqlite -site uxmal -table col_1
gee_extract.py -s LE7 -b 1980-01-01 -lon -89.8107 -lat 20.4159 -r 500 -db /tmp/gee_db.sqlite -site uxmal -table col_1
gee_extract.py -s LC8 -b 1980-01-01 -lon -89.8107 -lat 20.4159 -r 500 -db /tmp/gee_db.sqlite -site uxmal -table col_1
# Extract only tier 1 data for LC8
gee_extract.py -s LC8 -b 1980-01-01 -lon -89.8107 -lat 20.4159 -r 500 -db /tmp/gee_db.sqlite -site uxmal -table col_1 --tiers T1
Batch ordering CLI¶
usage: gee_extract_batch.py [-h] -b BEGIN [-e END] -db DB [-r RADIUS] -s
SENSOR -table TABLE [-stats STATS]
[-t [TIERS [TIERS ...]]]
file
positional arguments:
file Input text file with coma separated site coordinates
in DD and site name on each line.
optional arguments:
-h, --help show this help message and exit
-b BEGIN, --begin BEGIN
Anterior time-range boundary in yyyy-mm-dd
-e END, --end END Posterior time-range boundary in yyyy-mm-dd
-db DB, --db DB Path to sqlite database. Will be created if does not
exist
-r RADIUS, --radius RADIUS
Optional circular radius in meters around center point
-s SENSOR, --sensor SENSOR
Landsat sensor to query; one of LT4, LT5, LE7, LC8
-table TABLE, --table TABLE
Database table name to write data. Existing tables
will be appended
-stats STATS, --stats STATS
Spatial aggregation function, one of mean (default),
median, max or min. Only relevant if a radius value is
provided
-t [TIERS [TIERS ...]], --tiers [TIERS [TIERS ...]]
Tiers to order (T1: highest quality, defaults to T1
and T2)
Command line utility to batch extract Lansat surface reflectance data from the google earth
engine platform and write the output to a local sqlite database. Query can be done for
a single pixel, or for a circular region, in which case data are spatially aggregated
for each time step using the a user defined spatial aggregation function.
Input locations must be provided in a text file, with on each line lon,lat,site_name
site_name provided for each site in the text file is used (together with sensor) as grouping variable
in the sqlite table.
--------------------------
Example usage
--------------------------
# Extract all the LC8 bands in a 500 meters for two locations between 2012 and now
echo "4.7174,44.7814,rompon\n-149.4260,-17.6509,tahiti" > site_list.txt
gee_extract_batch.py site_list.txt -b 1984-01-01 -s LT5 -r 500 -db /tmp/gee_db.sqlite -table landsat_ts
gee_extract_batch.py site_list.txt -b 1984-01-01 -s LE7 -r 500 -db /tmp/gee_db.sqlite -table landsat_ts
gee_extract_batch.py site_list.txt -b 1984-01-01 -s LC8 -r 500 -db /tmp/gee_db.sqlite -table landsat_ts
# Only Tier 1 for LC8
gee_extract_batch.py site_list.txt -b 1984-01-01 -s LC8 -r 500 -db /tmp/gee_db.sqlite -table landsat_ts --tiers T1