Package: geextract
Google Earth Engine data extraction tool. Quickly obtain Landsat multispectral time-series for exploratory analysis and algorithm testingOnline documentation available athttps://loicdtx.github.io/landsat-extract-geeIntroductionA python library (API + command lines) to extract Landsat time-series from the Google Earth Engine platform. Can query single pixels or spatially aggregated values over polygons. When used via the command line, extracted time-series are written to a sqlite database.The idea is to provide quick access to Landsat time-series for exploratory analysis or algorithm testing. Instead of downloading the whole stack of Landsat scenes, preparing the data locally and extracting the time-series of interest, which may take several days,geextractallows to get time-series in a few seconds.Compatible with python 2.7 and 3.UsageAPIThe principal function of the API ists_extractfromgeextractimportts_extractfromdatetimeimportdatetime# Extract a Landsat 7 time-series for a 500m radius circular buffer around# a location in Yucatanlon=-89.8107197lat=20.4159611LE7_dict_list=ts_extract(lon=lon,lat=lat,sensor='LE7',start=datetime(1999,1,1),radius=500)Command linegeextractcomes with two command lines, for extracting Landsat time-series directly from the command line.gee_extract.py: Extract a Landsat multispectral time-series for a single site. Extracted data are automatically added to a sqlite database.gee_extract_batch.py: Batch order Landsat multispectral time-series for multiple locations.gee_extract.py--help# Extract all the LT5 bands for a location in Yucatan for the entire Landsat period, with a 500m radiusgee_extract.py-sLT5-b1980-01-01-lon-89.8107-lat20.4159-r500-db/tmp/gee_db.sqlite-siteuxmal-tablecol_1gee_extract.py-sLE7-b1980-01-01-lon-89.8107-lat20.4159-r500-db/tmp/gee_db.sqlite-siteuxmal-tablecol_1gee_extract.py-sLC8-b1980-01-01-lon-89.8107-lat20.4159-r500-db/tmp/gee_db.sqlite-siteuxmal-tablecol_1gee_extract_batch.py--help# Extract all the LC8 bands in a 500 meters for two locations between 2012 and nowecho"4.7174,44.7814,rompon\n-149.4260,-17.6509,tahiti">site_list.txtgee_extract_batch.pysite_list.txt-b1984-01-01-sLT5-r500-db/tmp/gee_db.sqlite-tablelandsat_tsgee_extract_batch.pysite_list.txt-b1984-01-01-sLE7-r500-db/tmp/gee_db.sqlite-tablelandsat_tsgee_extract_batch.pysite_list.txt-b1984-01-01-sLC8-r500-db/tmp/gee_db.sqlite-tablelandsat_tsInstallationYou must have aGoogle Earth Engineaccount to use the package.Then, in a vitual environment run:pipinstallgeextractearthengineauthenticateThis will open a google authentication page in your browser, and will give you an authentication token to paste back in the terminal.You can check that the authentication process was successful by running.python-c"import ee; ee.Initialize()"If nothing happens… it’s working.BenchmarkA quick benchmark of the extraction speed, using a 500 m buffer.importtimefromdatetimeimportdatetimefrompprintimportpprintimportgeextractlon=-89.8107197lat=20.4159611forsensorin['LT5','LE7','LT4','LC8']:start=time.time()out=geextract.ts_extract(lon=lon,lat=lat,sensor=sensor,start=datetime(1980,1,1,0,0),end=datetime.today(),radius=500)end=time.time()pprint('%s. Extracted%drecords in%.1fseconds'%(sensor,len(out),end-start))# 'LT5. Extracted 142 records in 1.9 seconds'
# 'LE7. Extracted 249 records in 5.8 seconds'
# 'LT4. Extracted 7 records in 1.0 seconds'
# 'LC8. Extracted 72 records in 2.4 seconds'