API REFERENCE¶
CCDC¶
-
buildSegmentTag
(nSegments)¶ Create sequence of segment strings
- Arguments
nSegments (Integer) – Number of segments to create labels for
- Returns
{ee.List) List of segment names (e.g. S1, S2)
-
buildBandTag
(tag, bandList)¶ Create sequence of band names for a given string tag
- Arguments
tag (string) – String tag to use (e.g. ‘RMSE’)
bandList (array) – List of band names to combine with tag
- Returns
{ee.List) List of band names combined with tag name
-
buildMagnitude
(fit, nSegments, bandList)¶ Extract CCDC magnitude image from current CCDC result format
- Arguments
fit (ee.Image) – Image with CCD results
nSegments (number) – Number of segments to extract
bandList (array) – Client-side list with band names to use
- Returns
{ee.Image) Image with magnitude of change per segment per band
-
buildRMSE
(fit, nSegments, bandList)¶ Extract CCDC RMSE image from current CCDC formatted results
- Arguments
fit (ee.Image) – Image with CCDC results
nSegments (number) – Number of segments to extract
bandList (array) – Client-side list with band names to use
- Returns
{ee.Image) Image with RMSE of each segment per band
-
buildCoefs
(fit, nSegments, bandList)¶ Extract CCDC Coefficients from current CCDC formatted result
- Arguments
fit (ee.Image) – Image with CCD results
nSegments (number) – Number of segments to extract
bandList (array) – Client-side list with band names to use
- Returns
{ee.Image) Image with coefficients per band
-
buildStartEndBreakProb
(fit, nSegments, tag)¶ Extract data for CCDC 1D-array, non-spectral bands (tStart, tEnd, tBreak, changeProb or numObs)
- Arguments
fit (ee.Image) – Image with CCD results
nSegments (integer) – Number of segments to extract
tag (string) – Client-side string to use as name in the output bands
- Returns
{ee.Image) Image with values for tStart, tEnd, tBreak, changeProb or numObs
-
buildCcdImage
(fit, nSegments, bandList)¶ Transform ccd results from array image to “long” multiband format
- Arguments
fit (ee.Image) – Image with CCD results
nSegments (number) – Number of segments to extract
bandList (array) – Client-side list with band names to use
- Returns
{ee.Image) Image with all results from CCD in ‘long’ image format
-
getSyntheticForYear
(image, date, dateFormat, band)¶ Create synthetic image for specified band
- Arguments
image (ee.Image) – Image with CCD results in long multi-band format
date (number) – Date to extract the segments for, in the format that ccd was run in
dateFormat (number) – Code of the date format that ccdc was run in (e.g. 1 for frac years)
band (string) – Band name to use for creation of synthetic image
- Returns
{ee.Image) Synthetic image for the given date and band
-
getMultiSynthetic
(image, date, dateFormat, band)¶ Create synthetic image for a list of bands
- Arguments
image (ee.Image) – Image with CCD results in long multi-band format
date (number) – Date to extract the segments for, in the format that ccd was run in
dateFormat (number) – Code of the date format that ccdc was run in (e.g. 1 for frac years)
band (array) – List of bands to get synthetic data for
- Returns
{ee.Image) Synthethic image for the given date and bands
-
fillNoData
(fit, nCoefs, nBands, clipGeom)¶ Note
Deprecated: (No longer necessary)
Replace nodata in CCD output and fill with zeros Assumes current CCDC result format
- Arguments
fit (ee.Image) – Image with CCD results
nCoefs (number) – Number of coefficients present in the results
nBands (number) – Number of spectral bands used to produce the results
clipGeom (ee.Geometry) – Geometry of the image that is being masked
- Returns
{ee.Image) Image with nodata areas replaced with zeros
-
dateToDays
(strDate)¶ Note
Deprecated: (No longer necessary)
Return a date as days from 01-01-0000
- Arguments
strDate (String) – Date in the format accepted by ee.Date
- Returns
ee.Number – Date expressed as days since 01-01-0000
-
filterCoefs
(ccdResults, date, band, coef, behavior)¶ Filter coefficients for a given date using a mask
- Arguments
ccdResults (ee.Image) – CCD results in long multi-band format
date (string) – Date in the same format that CCD was run with
band (string) – Band to select.
coef (string) – Coef to select. Options are “INTP”, “SLP”, “COS”, “SIN”, “COS2”, “SIN2”, “COS3”, “SIN3”, “RMSE”, “MAG”
behavior (String) – Method to find intersecting (‘normal’) or closest segment to given date (‘before’ or ‘after’) if no segment intersects directly
- Returns
ee.Image – Single band image with the values for the selected band/coefficient
-
normalizeIntercept
(intercept, start, end, slope)¶ Normalize the intercept to the middle of the segment time period, instead of the 0 time period.
- Arguments
intercept (ee.Image) – Image band representing model intercept
start (ee.Image) – Image band representing model slope date
end (ee.Image) – Image band representing model end date
slope (ee.Image) – Image band representing model slope
- Returns
ee.Image – Image band representing normalized intercept.
-
getCoef
(ccd, date, bandList, coef, behavior)¶ Get image of with a single coefficient for all bands
- Arguments
ccd (ee.Image) – results CCD results in long multi-band format
date (string) – Date in the same format that CCD was run with
bandList (array) – List of all bands to include.
coef (array) – Coef to select. Options are “INTP”, “SLP”, “COS”, “SIN”, “COS2”, “SIN2”, “COS3”, “SIN3”, “RMSE”, “MAG”
behavior (string) – Method to find intersecting (‘normal’) or closest segment to given date (‘before’ or ‘after’) if no segment intersects directly
- Returns
ee.Image – coefs Image with the values for the selected bands x coefficient
-
applyNorm
(bandCoefs, segStart, segEnd)¶ Apply normalization to intercepts
- Arguments
bandCoefs (ee.Image) – Band x coefficients image. Must include slopes
segStart (ee.Image) – Image with dates representing the start of the segment
segEnd (ee.Image) – Image with dates representing the end of the segment
- Returns
ee.Image – bandCoefs Updated input image with normalized intercepts
-
getMultiCoefs
(ccd, date, bandList, coef_list, cond, segNames, behavior)¶ Get image of with bands x coefficients given in a list
- Arguments
ccd (ee.Image) – results CCD results in long multi-band format
date (string) – Date in the same format that CCD was run with
bandList (array) – List of all bands to include. Options are “B1”, “B2”, “B3”, “B4”, “B5”, “B6”, “B7”
coef_list (list) – List of coefs to select. Options are “INTP”, “SLP”, “COS”, “SIN”, “COS2”, “SIN2”, “COS3”, “SIN3”, “RMSE”, “MAG”
cond (boolean) – Normalize intercepts? If true, requires “INTP” and “SLP” to be selected in coef_list.
segNames (ee.List) – List of segment names to use.
behavior (string) – Method to find intersecting (‘normal’) or closest segment to given date (‘before’ or ‘after’) if no segment intersects directly
- Returns
ee.Image – coefs Image with the values for the selected bands x coefficients
-
getChanges
(ccd, startDate, endDate, segNames)¶ Filter segments with change in a given range
- Arguments
ccd (ee.Image) – results CCD results in long multi-band format
startDate (Number) – Start date in the format that was used to run CCD
endDate (Number) – End date in the format that was used to run CCD
segNames (ee.List) – List of segment names matching the number of segments in the bands
- Returns
ee.Image – Mask image indicating which pixel/segments have changes in the specified time range.
-
filterMag
(ccd, startDate, endDate, band, segNames)¶ Obtain change with largest magnitude, timing of that break, and total number of breaks for a given date range and band
- Arguments
ccd (ee.Image) – results CCD results in long multi-band format
startDate (number) – Start date in the format that was used to run CCD
endDate (sumber) – End date in the format that was used to run CCD
band (string) – Spectral band
segNames (ee.List) – List of segment names matching the number of segments in the bands
- Returns
ee.Image – Image with three bands indicating: 1) Magnitude of the largest break for the given date range 2) Timing of largest break (in the time units CCDC was run in) 3) Total number of breaks in the date range
-
phaseAmplitude
(ccd, bands, sinName, cosName)¶ Get phase and amplitude for a single spectral band
- Arguments
ccd (ee.Image) – results CCD results in long multi-band format
bands (List) – List with the name of the bands for which to calculate ampl. and phase
sinName (String) – Band suffix of the desired sine harmonic coefficient (e.g ‘_SIN)
cosName (String) – Band suffix of the desired sine harmonic coefficient (e.g ‘_COS)
-
ccdc.
newPhaseAmplitude
(ccd, sinExpr, cosExpr)¶ Get phase and amplitude. Replace old function with this.
- Arguments
ccd (ee.Image) – results CCD results in long multi-band format
sinExpr (String) – Regular expression of the sine harmonic coefficient (e.g ‘.*SIN.*’) for all harmonics
cosExpr (String) – Regular expression of the cosine harmonic coefficient (e.g ‘.*COS.*) for all harmonics. Must retrieve the same number of bands as sinExpr
Inputs¶
-
getLandsat
(options, start, end, targetBands)¶ Get Landsat images for a specific region Possible bands and indices: BLUE, GREEN, RED, NIR, SWIR1, SWIR2, NDVI, NBR, EVI, EVI2,BRIGHTNESS, GREENNESS, WETNESS
- Arguments
options (ee.Dict) – Parameter file containing the keys below
start (String) – First date to filter images
end (String) – Last date to filter images
targetBands (list) – Bands and indices to return
- Returns
ee.ImageCol. Masked image collection with L4, L5, L7, and L8
-
generateCollection
(geom, startDate, endDate)¶ Generate and combine filtered collections of Landsat 4, 5, 7 and 8
- Arguments
geom (ee.Image) – Geometry used to filter the collection
startDate (String) – Initial date to filter the collection
endDate (String) – Final date to filter the collection
- Returns
ee.ImageCollection – Filtered Landsat collection
-
doIndices
(collection)¶ Calculate spectral indices for all bands in collection
- Arguments
collection (ee.ImageCollection) – Landsat image collection
- Returns
ee.ImageCollection – Landsat image with spectral indices
-
makeLatGrid
(options, minY, maxY, minX, size)¶ Create a grid with features corresponding to latitudinal strips
- Arguments
options (Dictionary) – parameter file
minY (Number) – minimum latititude coordinate
maxY (Number) – maximum latititude coordinate
minX (Number) – minimum longitude coordinate
minX – maximum longitude coordinate
size (Number) – size of features in units of latitudinal degrees
- Returns
ee.FeatureCollection – grid of features along latitudinal lines
-
makeLonGrid
(options, minY, maxY, minX, size)¶ Create a grid with features corresponding to longitudinal strips
- Arguments
options (Dictionary) – parameter file
minY (Number) – minimum latititude coordinate
maxY (Number) – maximum latititude coordinate
minX (Number) – minimum longitude coordinate
minX – maximum longitude coordinate
size (Number) – size of features in units of latitudinal degrees
- Returns
ee.FeatureCollection – grid of features along longitudinal lines
-
makeLonLatGrid
(minY, maxY, minX, size)¶ Create a grid with features corresponding to longitudinal strips
- Arguments
minY (Number) – minimum latititude coordinate
maxY (Number) – maximum latititude coordinate
minX (Number) – minimum longitude coordinate
minX – maximum longitude coordinate
size (Number) – size of features in units of latitudinal degrees
- Returns
ee.FeatureCollection – grid of features along longitudinal lines
-
getAncillary
()¶ Get ancillary data for trainning and classification.
- Returns
ee.Image – Multi-band image containing ancillary layers
-
getS2
(roi)¶ Get Sentinel-2 surface reflectance data. Taken directly from GEE examples repo.
- Arguments
roi (ee.Geometry) – target study area to filter data
- Returns
(ee.ImageCollection) Sentinel-2 SR and spectral indices
-
getS1
(mode="'ASCENDING'", focalSize=3)¶ Get Sentinel 1 data
- Arguments
mode (string) – orbital pass mode (‘ASCENDING’ or ‘DESCENDING’)
focalSize (number) – window size for focal mean (1 means no averaging)
- Returns
ee.ImageCollection – Sentinel 1 collection with VH, VV, and ratio bands smoothed with focal mean
-
calcNDFI
(Surface)¶ Calculate NDFI using endmembers from Souza et al., 2005
- Arguments
Surface (ee.Image) – reflectance image with 6 bands (i.e. not thermal)
- Returns
ee.Image – NDFI transform
-
makeCcdImage
(metadataFilter, segs, numberOfSegments, bandNames, inputFeatures)¶ Make a ccd image from the most recent known global run
- Arguments
metadataFilter (String) – Which ccdc run prefix to use
segs (List) – List with the segment names
numberOfSegments (Number) – Max number of segments to retrieve from the CCDC results
bandNames (List) – List with the band names to use
inputFeatures (List) – List with the CCDC features to extract
- Returns
ee.Image – Filtered CCDC results in ‘long’ format
-
calcNDVI
(image)¶ Calculate NDVI for an image
- Arguments
image (ee.Image) – Landsat image with NIR and RED bands
- Returns
ee.Image – NDVI image
-
calcNBR
(image)¶ Calculate NBR for an image
- Arguments
image (ee.Image) – Landsat image with NIR and SWIR2 bands
- Returns
ee.Image – NBR image
-
calcEVI
(image)¶ Calculate EVI for an image
- Arguments
image (ee.Image) – Landsat image with NIR, RED, and BLUE bands
- Returns
ee.Image – EVI transform
-
calcEVI2
(image)¶ Calculate EVI2 for an image
- Arguments
image (ee.Image) – Landsat image with NIR and RED
- Returns
ee.Image – EVI2 transform
-
tcTrans
(image)¶ Tassel Cap coefficients from Crist 1985
- Arguments
image (ee.Image) – Landsat image with BLUE, GREEN, RED, NIR, SWIR1, and SWIR2
- Returns
ee.Image – 3-band image with Brightness, Greenness, and Wetness
-
makeAutoGrid
(geo, size)¶ Create a grid with features overlaying the bounding box of a geometry
- Arguments
geo (ee.Geometry) – geometry to use as spec for grid
size (Number) – size of features in units of degrees
- Returns
ee.FeatureCollection – grid of features along
Classification¶
-
getMiddleDate
(fc, startProp, endProp, middleProp)¶ Get the middle segment date of training data
- Arguments
fc (ee.FeatureCollection) – Training data feature collection
startProp (string) – Property name of segment start year
endProp (String) – Property name of segment end year
middleProp (String) – Property name of calculated middle attribute
- Returns
ee.FeatureCollection – Training data with middleProp attribute
-
makeGrids
(region, count, size, seed)¶ Make random grids in a region of interest
- Arguments
region (ee.Geometry) – study region bounding geometry
count (number) – number of random grids
size (number) – length of one side of grid in m^2
seed (number) – random number seed or ‘random’
- Returns
ee.FeatureCollection – feature collection of random grids
-
getBinaryLabel
(fc, property, targetClass)¶ Convert training data to binary label for target class
- Arguments
fc (ee.FeatureCollection) – Training data feature collection
property (string) – Property label indicating class label
targetClass (number) – Class to retain as 1 in binary label
- Returns
ee.FeatureCollection – Training data where 1 = targetClass and 0 equals all other classes
-
getClassProbs
(fc, coefsToClassify, classList, classifier, property)¶ Get class probability for each class in training data
- Arguments
fc (ee.FC) – feature collection of training data
coefsToClassify (ee.Image) – multi-band image of coefficients to classify
classList (list) – classes to test probability of
classifier (ee.Classifier) – in ‘PROBABILITY’ mode
property (string) – label defining class in training data
- Returns
ee.Image – image with each band being class probability for each input class
-
getTrainingCoefsAtDate
(trainingData, coefNames=['INTP','SLP','COS','SIN','RMSE','COS2','SIN2','COS3','SIN3'], bandList=['BLUE','GREEN','RED','NIR','SWIR1','SWIR2'], dateProperty="'Start_Year'", extraBands=null, ccdcImage=null, segs=["S1", "S2", "S3", "S4", "S5", "S6"], ccdcDateFmt=1, trainingDateFmt=1, scale=30, landsatParams={start: '1990-01-01',end: '2020-01-01'})¶ Get coefficients at a given date for each feature in collection
- Arguments
trainingData (ee.FeatureCollection) – training data points to extract coefficients for
coefNames (List) – coefficient abbreviated names in order of results
bandList (List) – list of input band names in order
dateProperty (string) – property name containing date in features
extraBands (List) – ancillary bands to add as predictors
ccdcImage (ee.Image) – Use ccdc coefficients instead of calculating on the fly
segs (List) – Segment identifiers for ccdcImage parameter
ccdcDateFmt (number) – date format of ccdc date format
trainingDateFmt (number) – training data date format (according to ccdc syntax)
scale (number) – spatial scale to sample training points at
landsatParams (Object) – parameters for ‘getLandsat’ function
- Returns
ee.FeatureCollection – training data with coefficients corresponding to specific date
-
remapLC
(feats, inLabel, outLabel, inList, outList)¶ Remap training labels to GLANCE level 1 land cover
- Arguments
feats (ee.FeatureCollection) – training data feature collection
inLabel (string) – attribute name containing land cover strings
outLabel (string) – attribute name for output numeric land cover
inList (list) – list of input land cover string values
outList (list) – list of output land cover numeric values
- Returns
ee.FeatureCollection – training data feature collection with numeric ‘outLabel’ column in each feature
-
assignIds
(sample, attributeName="ID")¶ Shuffle the sample and assign sample ID
- Arguments
sample (ee.FeatureCollection) – training data of point samples
attributeName (string) – name to assign ID attribute to
- Returns
ee.FeatureCollection – training data shuffled with unique ID attribute
-
makeLegend
(classes, palette, title="'Legend'", width="'250px'", position="'bottom-right'")¶ Make a legend widget
- Arguments
classes (array) – list of input classes
palette (array) – list of color palette
title (string) – legend title (optional)
width (string) – width of panel (optional)
position (string) – position on map (optional)
- Returns
ui.Panel – legend panel to display on map
-
classifyCoefs
(imageToClassify, bandNames, ancillary, ancillaryFeatures, trainingData, classifier, studyArea, classProperty="'LC_Num'", coefs, trainProp=.4, seed='random')¶ Classify single set of CCDC coefficients. Useful for quick parameter testing and debugging.
- Arguments
imageToClassify (ee.Image) – Single set of ccdc coefficients to classify
bandNames (array) – list of band names to classify
ancillary (array) – list of ancillary predictor data
ancillaryFeatures (ee.Image) – ancillary data image
trainingData (ee.FeatureCollection) – training data
classifier (ee.Classifier) – earth engine classifier with parameters
studyArea (ee.Geometry) – boundaries of region to subset training data, null uses all data.
classProperty (string) – attribute name with land cover label
coefs (array) – list of coefficients to classify
trainProp (float) – proportion of data to use subset for training
seed (number) – seed to use for the random column generator
- Returns
ee.Image – classified image
-
classifySegments
(imageToClassify, numberOfSegments, bandNames, ancillary, ancillaryFeatures, trainingData, classifier, studyArea, classProperty="'LC_Num'", coefs, trainProp=.4, seed='random', subsetTraining=true)¶ Classify stack of CCDC coefficient, band-separated by segment
- Arguments
imageToClassify (ee.Image) – ccdc coefficient stack to classify
numberOfSegments (number) – number of segments to classify
bandNames (array) – list of band names to classify
ancillary (array) – list of ancillary predictor data
ancillaryFeatures (ee.Image) – ancillary data image
trainingData (ee.FeatureCollection) – training data
classifier (ee.Classifier) – earth engine classifier with parameters
studyArea (ee.Geometry) – boundaries of region to subset training data, null uses all data.
classProperty (string) – attribute name with land cover label
coefs (array) – list of coefficients to classify
trainProp (float) – proportion of data to use subset for training
seed (number) – seed to use for the random column generator
subsetTraining (boolean) – true to subset training to geometry, false to not
- Returns
ee.Image – classified stack of CCDC segments
-
parseConfMatrix
(im, attribute="'confMatrix'")¶ Parse confusion matrix from string
- Arguments
im (ee.Image) – classified image with confusion matrix in metadata
attribute (string) – name of attribute with confusion matrix
-
accuracyProcedure
(trainingData, imageToClassify, predictors, bandNames, ancillary, classifier, classProperty="'LC_Num'", seed='random', trainProp=.4)¶ Calculate accuracy metrics using a subset of the training data
- Arguments
trainingData (ee.FeatureCollection) – training data
imageToClassify (ee.Image) – ccdc coefficient stack to classify
predictors (array) – list of predictor variables as strings
bandNames (array) – list of band names to classify
ancillary (array) – list of ancillary predictor data
classifier (ee.Classifier) – earth engine classifier with parameters
classProperty (string) – attribute name with land cover label
seed (number) – seed to use for the random column generator
trainProp (float) – proportion of data to use subset for training
- Returns
ee.ConfusionMatrix – a confusion matrix as calculated by the train/test subset
-
getLcAtDate
(segs, date, numberOfSegments, ccdVersion, metadataFilter, behavior, bandNames, inputFeatures)¶ Calculate landcover at a date based on pre-classified segments
- Arguments
segs (ee.Image) – classified ccd segment image
date (string) – date of land cover to retrieve in format ‘YYYY-MM-DD’
numberOfSegments (number) – number of segments in classification image
ccdVersion (string) – version of ccd used for classification
metadataFilter (string) – metadata used for classification of ccd
behavior (string) – behavior when date is in between segments (‘none’,’before’,’after’)
bandNames (array) – list of band names (such as “BLUE”,”GREEN”)
inputFeatures (array) – list of input feature names (such as “INTP” and “RMSE”)
- Returns
ee.Image – matchingDate landcover classification image at date specified in parameter
-
getMode
(folder, matchingString)¶ Get mode classification from a stack of overlapping result files
- Arguments
folder (string) – the path to the folder containing the result files
matchingString (string) – an identifier in the result file names
- Returns
ee.Image – band-wise mode classification
Dates¶
-
msToDays
(ms)¶ milliseconds since epoch (01-01-1970 ) to number of days
- Arguments
ms (Number) – ms since 01-01-1970)
- Returns
ee.Number – milliseconds since epoch
-
dateToJdays
(str_date)¶ Convert Date to julian days (i.e. days since 01-01-0001)
- Arguments
str_date (String) – Date string in yyyy-mm-dd format
- Returns
ee.Number – Julian day
-
jdaysToms
(jdays)¶ Convert julian day (i.e. days since 01-01-0001) to ms since 1970-01-01
- Arguments
jdays (Number) – Julian day
- Returns
ee.Number – ms since 1970-01-01
-
jdaysToDate
(jdays)¶ Convert julian day (i.e. days since 01-01-0001) to ee.Date
- Arguments
jdays (Number) – Julian day
- Returns
ee.Date – ee.Date
-
msToJdays
(ms)¶ Convert ms since 1970-01-01 to julian day (i.e. days since 01-01-0001)
- Arguments
ms (Number) – ms since 1970-01-01
- Returns
ee.Number – Julian day
-
msToFrac
(ms)¶ Convert ms since 1970-01-01 to fractional year
- Arguments
ms (Number) – ms since 1970-01-01
- Returns
ee.Number – Fractional year
-
msToDate
(ms)¶ Convert ms to ee.Date
- Arguments
ms (number) – jdays as milleconds
- Returns
ee.Date – ee.Date
-
fracToms
(frac)¶ Convert fractional time to ms since 1970-01-01. DOES NOT ACCOUNT FOR LEAP YEARS
- Arguments
frac (Number) – Fractional year
- Returns
ee.Number – ms since 1970-01-01
-
convertDate
(options)¶ Convert between any two date formats
- Arguments
options (Dictionary) – parameter dictionary
- Returns
Object – output reformatted date