ee package¶
Subpackages¶
Submodules¶
ee.apifunction module¶
A class for representing built-in EE API Function.
Earth Engine can dynamically produce a JSON array listing the algorithms available to the user. Each item in the dictionary identifies the name and return type of the algorithm, the name and type of its arguments, whether they’re required or optional, default values and docs for each argument and the algorithms as a whole.
This class manages the algorithm dictionary and creates JavaScript functions to apply each EE algorithm.
-
class
ee.apifunction.
ApiFunction
(name, opt_signature=None)¶ Bases:
ee.function.Function
An object representing an EE API Function.
-
classmethod
allSignatures
()¶ Returns a map from the name to signature for all API functions.
-
classmethod
apply_
(name, named_args)¶ Call a named API function with a dictionary of named arguments.
- Args:
- name: The name of the API function to call. named_args: A dictionary of arguments to the function.
- Returns:
- An object representing the called function. If the signature specifies a recognized return type, the returned value will be cast to that type.
-
classmethod
call_
(name, *args, **kwargs)¶ Call a named API function with positional and keyword arguments.
- Args:
- name: The name of the API function to call. *args: Positional arguments to pass to the function. **kwargs: Keyword arguments to pass to the function.
- Returns:
- An object representing the called function. If the signature specifies a recognized return type, the returned value will be cast to that type.
-
static
clearApi
(target)¶ Removes all methods added by importApi() from a target class.
- Args:
- target: The class to remove from.
-
encode_cloud_invocation
(unused_encoder)¶ Encodes the function as a FunctionInvocation.
- Args:
- encoder: A function that can be called to encode the components of
- an object. Returns a reference to the encoded value.
- Returns:
- The encoded form of the function.
-
encode_invocation
(unused_encoder)¶ Encodes the function in a format compatible with Serializer.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the function.
-
getSignature
()¶ Returns a description of the interface provided by this function.
-
classmethod
importApi
(target, prefix, type_name, opt_prepend=None)¶ Adds all API functions that begin with a given prefix to a target class.
- Args:
target: The class to add to. prefix: The prefix to search for in the signatures. type_name: The name of the object’s type. Functions whose
first argument matches this type are bound as instance methods, and those whose first argument doesn’t match are bound as static methods.- opt_prepend: An optional string to prepend to the names of the
- added functions.
-
classmethod
initialize
()¶ Initializes the list of signatures from the Earth Engine front-end.
-
classmethod
lookup
(name)¶ Looks up an API function by name.
- Args:
- name: The name of the function to get.
- Returns:
- The requested ApiFunction.
-
classmethod
lookupInternal
(name)¶ Looks up an API function by name.
- Args:
- name: The name of the function to get.
- Returns:
- The requested ApiFunction or None if not found.
-
classmethod
reset
()¶ Clears the API functions list so it will be reloaded from the server.
-
classmethod
unboundFunctions
()¶ Returns the functions that have not been bound using importApi() yet.
-
classmethod
ee.apitestcase module¶
A TestCase that initializes the library with standard API methods.
-
class
ee.apitestcase.
ApiTestCase
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
InitializeApi
()¶ Initializes the library with standard API methods.
This is normally invoked during setUp(), but subclasses may invoke it manually instead if they prefer.
-
MockSend
(path, params, unused_method=None, unused_raw=None)¶
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
-
ee.apitestcase.
UsingCloudApi
(cloud_api_resource=None, mock_http=None)¶ Returns a context manager under which the Cloud API is enabled.
ee.batch module¶
An interface to the Earth Engine batch processing system.
Use the static methods on the Export class to create export tasks, call start() on them to launch them, then poll status() to find out when they are finished. The public function styling uses camelCase to match the JavaScript names.
-
ee.batch.
ConvertFormatSpecificParams
(configDict)¶ Mutates configDict into server params by extracting format options.
- For example:
- {‘fileFormat’: ‘GeoTIFF’, ‘formatOptions’: {‘cloudOptimized’: true}}
- becomes:
- {‘fileFormat’: ‘GeoTIFF’, ‘tiffCloudOptimized’: true}
Also performs checks to make sure any specified options are valid and/or won’t collide with top level arguments when converted to server-friendly parameters.
- Args:
- configDict: A task config dict
- Raises:
- EEException: We were unable to create format specific parameters for the server.
-
class
ee.batch.
Export
¶ Bases:
object
A class with static methods to start export tasks.
-
class
image
¶ Bases:
object
A static class with methods to start image export tasks.
-
static
toAsset
(image, description='myExportImageTask', assetId=None, pyramidingPolicy=None, dimensions=None, region=None, scale=None, crs=None, crsTransform=None, maxPixels=None, **kwargs)¶ Creates a task to export an EE Image to an EE Asset.
- Args:
image: The image to be exported. description: Human-readable name of the task. assetId: The destination asset ID. pyramidingPolicy: The pyramiding policy to apply to each band in the
image, a dictionary keyed by band name. Values must be one of: “mean”, “sample”, “min”, “max”, or “mode”. Defaults to “mean”. A special key, “.default”, may be used to change the default for all bands.- dimensions: The dimensions of the exported image. Takes either a
- single positive integer as the maximum dimension or “WIDTHxHEIGHT” where WIDTH and HEIGHT are each positive integers.
- region: The lon,lat coordinates for a LinearRing or Polygon
- specifying the region to export. Can be specified as a nested lists of numbers or a serialized string. Defaults to the image’s region.
- scale: The resolution in meters per pixel. Defaults to the
- native resolution of the image assset unless a crsTransform is specified.
- crs: The coordinate reference system of the exported image’s
- projection. Defaults to the image’s default projection.
- crsTransform: A comma-separated string of 6 numbers describing
- the affine transform of the coordinate reference system of the exported image’s projection, in the order: xScale, xShearing, xTranslation, yShearing, yScale and yTranslation. Defaults to the image’s native CRS transform.
- maxPixels: The maximum allowed number of pixels in the exported
- image. The task will fail if the exported region covers more pixels in the specified projection. Defaults to 100,000,000.
- **kwargs: Holds other keyword arguments that may have been deprecated
- such as ‘crs_transform’.
- Returns:
- An unstarted Task that exports the image to Drive.
-
static
toCloudStorage
(image, description='myExportImageTask', bucket=None, fileNamePrefix=None, dimensions=None, region=None, scale=None, crs=None, crsTransform=None, maxPixels=None, shardSize=None, fileDimensions=None, skipEmptyTiles=None, fileFormat=None, formatOptions=None, **kwargs)¶ Creates a task to export an EE Image to Google Cloud Storage.
- Args:
image: The image to be exported. description: Human-readable name of the task. bucket: The name of a Cloud Storage bucket for the export. fileNamePrefix: Cloud Storage object name prefix for the export.
Defaults to the name of the task.- dimensions: The dimensions of the exported image. Takes either a
- single positive integer as the maximum dimension or “WIDTHxHEIGHT” where WIDTH and HEIGHT are each positive integers.
- region: The lon,lat coordinates for a LinearRing or Polygon
- specifying the region to export. Can be specified as a nested lists of numbers or a serialized string. Defaults to the image’s region.
- scale: The resolution in meters per pixel. Defaults to the
- native resolution of the image assset unless a crsTransform is specified.
- crs: The coordinate reference system of the exported image’s
- projection. Defaults to the image’s default projection.
- crsTransform: A comma-separated string of 6 numbers describing
- the affine transform of the coordinate reference system of the exported image’s projection, in the order: xScale, xShearing, xTranslation, yShearing, yScale and yTranslation. Defaults to the image’s native CRS transform.
- maxPixels: The maximum allowed number of pixels in the exported
- image. The task will fail if the exported region covers more pixels in the specified projection. Defaults to 100,000,000.
- shardSize: Size in pixels of the shards in which this image will be
- computed. Defaults to 256.
- fileDimensions: The dimensions in pixels of each image file, if the
- image is too large to fit in a single file. May specify a single number to indicate a square shape, or a tuple of two dimensions to indicate (width,height). Note that the image will still be clipped to the overall image dimensions. Must be a multiple of shardSize.
- skipEmptyTiles: If true, skip writing empty (i.e. fully-masked)
- image tiles. Defaults to false.
- fileFormat: The string file format to which the image is exported.
- Currently only ‘GeoTIFF’ and ‘TFRecord’ are supported, defaults to ‘GeoTIFF’.
formatOptions: A dictionary of string keys to format specific options. **kwargs: Holds other keyword arguments that may have been deprecated
such as ‘crs_transform’.- Returns:
- An unstarted Task that exports the image to Google Cloud Storage.
-
static
toDrive
(image, description='myExportImageTask', folder=None, fileNamePrefix=None, dimensions=None, region=None, scale=None, crs=None, crsTransform=None, maxPixels=None, shardSize=None, fileDimensions=None, skipEmptyTiles=None, fileFormat=None, formatOptions=None, **kwargs)¶ Creates a task to export an EE Image to Drive.
- Args:
image: The image to be exported. description: Human-readable name of the task. folder: The name of a unique folder in your Drive account to
export into. Defaults to the root of the drive.- fileNamePrefix: The Google Drive filename for the export.
- Defaults to the name of the task.
- dimensions: The dimensions of the exported image. Takes either a
- single positive integer as the maximum dimension or “WIDTHxHEIGHT” where WIDTH and HEIGHT are each positive integers.
- region: The lon,lat coordinates for a LinearRing or Polygon
- specifying the region to export. Can be specified as a nested lists of numbers or a serialized string. Defaults to the image’s region.
- scale: The resolution in meters per pixel. Defaults to the
- native resolution of the image assset unless a crsTransform is specified.
- crs: The coordinate reference system of the exported image’s
- projection. Defaults to the image’s default projection.
- crsTransform: A comma-separated string of 6 numbers describing
- the affine transform of the coordinate reference system of the exported image’s projection, in the order: xScale, xShearing, xTranslation, yShearing, yScale and yTranslation. Defaults to the image’s native CRS transform.
- maxPixels: The maximum allowed number of pixels in the exported
- image. The task will fail if the exported region covers more pixels in the specified projection. Defaults to 100,000,000.
- shardSize: Size in pixels of the shards in which this image will be
- computed. Defaults to 256.
- fileDimensions: The dimensions in pixels of each image file, if the
- image is too large to fit in a single file. May specify a single number to indicate a square shape, or a tuple of two dimensions to indicate (width,height). Note that the image will still be clipped to the overall image dimensions. Must be a multiple of shardSize.
- skipEmptyTiles: If true, skip writing empty (i.e. fully-masked)
- image tiles. Defaults to false.
- fileFormat: The string file format to which the image is exported.
- Currently only ‘GeoTIFF’ and ‘TFRecord’ are supported, defaults to ‘GeoTIFF’.
formatOptions: A dictionary of string keys to format specific options. **kwargs: Holds other keyword arguments that may have been deprecated
such as ‘crs_transform’, ‘driveFolder’, and ‘driveFileNamePrefix’.- Returns:
- An unstarted Task that exports the image to Drive.
-
static
-
class
map
¶ Bases:
object
A class with a static method to start map export tasks.
-
static
toCloudStorage
(image, description='myExportMapTask', bucket=None, fileFormat=None, path=None, writePublicTiles=None, maxZoom=None, scale=None, minZoom=None, region=None, skipEmptyTiles=None, mapsApiKey=None, **kwargs)¶ Creates a task to export an Image as a pyramid of map tiles.
Exports a rectangular pyramid of map tiles for use with web map viewers. The map tiles will be accompanied by a reference index.html file that displays them using the Google Maps API, and an earth.html file for opening the map on Google Earth.
- Args:
image: The image to export as tiles. description: Human-readable name of the task. bucket: The destination bucket to write to. fileFormat: The map tiles’ file format, one of ‘auto’, ‘png’,
or ‘jpeg’. Defaults to ‘auto’, which means that opaque tiles will be encoded as ‘jpg’ and tiles with transparency will be encoded as ‘png’.- path: The string used as the output’s path. A trailing ‘/’
- is optional. Defaults to the task’s description.
- writePublicTiles: Whether to write public tiles instead of using the
- bucket’s default object ACL. Defaults to True and requires the invoker to be an OWNER of bucket.
maxZoom: The maximum zoom level of the map tiles to export. scale: The max image resolution in meters per pixel, as an alternative
to ‘maxZoom’. The scale will be converted to the most appropriate maximum zoom level at the equator.minZoom: The optional minimum zoom level of the map tiles to export. region: The lon,lat coordinates for a LinearRing or Polygon
specifying the region to export. Can be specified as a nested lists of numbers or a serialized string. Map tiles will be produced in the rectangular region containing this geometry. Defaults to the image’s region.- skipEmptyTiles: If true, skip writing empty (i.e. fully-transparent)
- map tiles. Defaults to false.
- mapsApiKey: Used in index.html to initialize the Google Maps API. This
- removes the “development purposes only” message from the map.
- **kwargs: Holds other keyword arguments that may have been deprecated
- such as ‘crs_transform’.
- Returns:
- An unstarted Task that exports the image to Google Cloud Storage.
-
static
-
class
table
¶ Bases:
object
A class with static methods to start table export tasks.
-
static
toAsset
(collection, description='myExportTableTask', assetId=None, **kwargs)¶ Creates a task to export a FeatureCollection to an EE table asset.
- Args:
- collection: The feature collection to be exported. description: Human-readable name of the task. assetId: The destination asset ID. **kwargs: Holds other keyword arguments that may have been deprecated.
- Returns:
- An unstarted Task that exports the table.
-
static
toCloudStorage
(collection, description='myExportTableTask', bucket=None, fileNamePrefix=None, fileFormat=None, selectors=None, **kwargs)¶ Creates a task to export a FeatureCollection to Google Cloud Storage.
- Args:
collection: The feature collection to be exported. description: Human-readable name of the task. bucket: The name of a Cloud Storage bucket for the export. fileNamePrefix: Cloud Storage object name prefix for the export.
Defaults to the name of the task.- fileFormat: The output format: “CSV” (default), “GeoJSON”, “KML”, “KMZ”,
- “SHP”, or “TFRecord”.
- selectors: The list of properties to include in the output, as a list
- of strings or a comma-separated string. By default, all properties are included.
- **kwargs: Holds other keyword arguments that may have been deprecated
- such as ‘outputBucket’.
- Returns:
- An unstarted Task that exports the table.
-
static
toDrive
(collection, description='myExportTableTask', folder=None, fileNamePrefix=None, fileFormat=None, selectors=None, **kwargs)¶ Creates a task to export a FeatureCollection to Google Cloud Storage.
- Args:
collection: The feature collection to be exported. description: Human-readable name of the task. folder: The name of a unique folder in your Drive account to
export into. Defaults to the root of the drive.- fileNamePrefix: The Google Drive filename for the export.
- Defaults to the name of the task.
- fileFormat: The output format: “CSV” (default), “GeoJSON”, “KML”,
- “KMZ”, “SHP”, or “TFRecord”.
- selectors: The list of properties to include in the output, as a list
- of strings or a comma-separated string. By default, all properties are included.
- **kwargs: Holds other keyword arguments that may have been deprecated
- such as ‘driveFolder’ and ‘driveFileNamePrefix’.
- Returns:
- An unstarted Task that exports the table.
-
static
-
class
video
¶ Bases:
object
A class with static methods to start video export task.
-
static
toCloudStorage
(collection, description='myExportVideoTask', bucket=None, fileNamePrefix=None, framesPerSecond=None, dimensions=None, region=None, scale=None, crs=None, crsTransform=None, maxPixels=None, maxFrames=None, **kwargs)¶ Creates a task to export an ImageCollection video to Cloud Storage.
- Args:
- collection: The image collection to be exported. The collection must
- only contain RGB images.
description: Human-readable name of the task. bucket: The name of a Cloud Storage bucket for the export. fileNamePrefix: Cloud Storage object name prefix for the export.
Defaults to the task’s description.- framesPerSecond: A number between .1 and 120 describing the
- framerate of the exported video.
- dimensions: The dimensions of the exported video. Takes either a
- single positive integer as the maximum dimension or “WIDTHxHEIGHT” where WIDTH and HEIGHT are each positive integers.
- region: The lon,lat coordinates for a LinearRing or Polygon
- specifying the region to export. Can be specified as a nested lists of numbers or a serialized string. Defaults to the first image’s region.
scale: The resolution in meters per pixel. crs: The coordinate reference system of the exported video’s
projection. Defaults to SR-ORG:6627.- crsTransform: A comma-separated string of 6 numbers describing
- the affine transform of the coordinate reference system of the exported video’s projection, in the order: xScale, xShearing, xTranslation, yShearing, yScale and yTranslation. Defaults to the image collection’s native CRS transform.
- maxPixels: The maximum number of pixels per frame.
- Defaults to 1e8 pixels per frame. By setting this explicitly, you may raise or lower the limit.
- maxFrames: The maximum number of frames to export.
- Defaults to 1000 frames. By setting this explicitly, you may raise or lower the limit.
- **kwargs: Holds other keyword arguments that may have been deprecated
- such as ‘crs_transform’.
- Returns:
- An unstarted Task that exports the image collection to Google Cloud Storage.
-
static
toDrive
(collection, description='myExportVideoTask', folder=None, fileNamePrefix=None, framesPerSecond=None, dimensions=None, region=None, scale=None, crs=None, crsTransform=None, maxPixels=None, maxFrames=None, **kwargs)¶ Creates a task to export an ImageCollection as a video to Drive.
- Args:
- collection: The image collection to be exported. The collection must
- only contain RGB images.
description: Human-readable name of the task. folder: The name of a unique folder in your Drive account to
export into. Defaults to the root of the drive.- fileNamePrefix: The Google Drive filename for the export.
- Defaults to the name of the task.
- framesPerSecond: A number between .1 and 120 describing the
- framerate of the exported video.
- dimensions: The dimensions of the exported video. Takes either a
- single positive integer as the maximum dimension or “WIDTHxHEIGHT” where WIDTH and HEIGHT are each positive integers.
- region: The lon,lat coordinates for a LinearRing or Polygon
- specifying the region to export. Can be specified as a nested lists of numbers or a serialized string. Defaults to the first image’s region.
scale: The resolution in meters per pixel. crs: The coordinate reference system of the exported video’s
projection. Defaults to SR-ORG:6627.- crsTransform: A comma-separated string of 6 numbers describing
- the affine transform of the coordinate reference system of the exported video’s projection, in the order: xScale, xShearing, xTranslation, yShearing, yScale and yTranslation. Defaults to the image collection’s native CRS transform.
- maxPixels: The maximum number of pixels per frame.
- Defaults to 1e8 pixels per frame. By setting this explicitly, you may raise or lower the limit.
- maxFrames: The maximum number of frames to export.
- Defaults to 1000 frames. By setting this explicitly, you may raise or lower the limit.
- **kwargs: Holds other keyword arguments that may have been deprecated
- such as ‘crs_transform’.
- Returns:
- An unstarted Task that exports the image collection to Drive.
-
static
-
class
-
class
ee.batch.
Task
(task_id, task_type, state, config=None, name=None)¶ Bases:
object
A batch task that can be run on the EE batch processing system.
-
class
ExportDestination
¶ Bases:
object
-
ASSET
= 'ASSET'¶
-
DRIVE
= 'DRIVE'¶
-
GCS
= 'GOOGLE_CLOUD_STORAGE'¶
-
-
class
State
¶ Bases:
object
-
CANCELLED
= 'CANCELLED'¶
-
CANCEL_REQUESTED
= 'CANCEL_REQUESTED'¶
-
COMPLETED
= 'COMPLETED'¶
-
FAILED
= 'FAILED'¶
-
READY
= 'READY'¶
-
RUNNING
= 'RUNNING'¶
-
UNSUBMITTED
= 'UNSUBMITTED'¶
-
-
class
Type
¶ Bases:
object
-
EXPORT_IMAGE
= 'EXPORT_IMAGE'¶
-
EXPORT_MAP
= 'EXPORT_TILES'¶
-
EXPORT_TABLE
= 'EXPORT_FEATURES'¶
-
EXPORT_VIDEO
= 'EXPORT_VIDEO'¶
-
-
active
()¶ Returns whether the task is still running.
-
cancel
()¶ Cancels the task.
-
static
list
()¶ Returns the tasks submitted to EE by the current user.
These include all currently running tasks as well as recently canceled or failed tasks.
- Returns:
- A list of Tasks.
-
start
()¶ Starts the task. No-op for started tasks.
-
status
()¶ Fetches the current status of the task.
- Returns:
- A dictionary describing the current status of the task as it appears on the EE server. Includes the following fields: - state: One of the values in Task.State. - creation_timestamp_ms: The Unix timestamp of when the task was created. - update_timestamp_ms: The Unix timestamp of when the task last changed. - output_url: URL of the output. Appears only if state is COMPLETED. - error_message: Failure reason. Appears only if state is FAILED. May also include other fields.
-
class
ee.collection module¶
Common representation for ImageCollection and FeatureCollection.
This class is never intended to be instantiated by the user.
-
class
ee.collection.
Collection
(func, args, opt_varName=None)¶ Bases:
ee.element.Element
Base class for ImageCollection and FeatureCollection.
-
static
elementType
()¶ Returns the type of the collection’s elements.
-
filter
(new_filter)¶ Apply a filter to this collection.
- Args:
- new_filter: Filter to add to this collection.
- Returns:
- The filtered collection object.
-
filterBounds
(geometry)¶ Shortcut to add a geometry filter to a collection.
Items in the collection with a footprint that fails to intersect the given geometry will be excluded when the collection is evaluated. This is equivalent to self.filter(Filter().geometry(…)).
- Args:
- geometry: The boundary to filter to either as a GeoJSON geometry,
- or a FeatureCollection, from which a geometry will be extracted.
- Returns:
- The filter object.
-
filterDate
(start, opt_end=None)¶ Shortcut to filter a collection with a date range.
Items in the collection with a time_start property that doesn’t fall between the start and end dates will be excluded. This is equivalent to self.filter(Filter().date(…)).
- Args:
- start: The start date as a Date object, a string representation of
- a date, or milliseconds since epoch.
- opt_end: The end date as a Date object, a string representation of
- a date, or milliseconds since epoch.
- Returns:
- The filter object.
-
filterMetadata
(name, operator, value)¶ Shortcut to add a metadata filter to a collection.
This is equivalent to self.filter(Filter().metadata(…)).
- Args:
name: Name of a property to filter. operator: Name of a comparison operator as defined
by FilterCollection. Possible values are: “equals”, “less_than”, “greater_than”, “not_equals”, “not_less_than”, “not_greater_than”, “starts_with”, “ends_with”, “not_starts_with”, “not_ends_with”, “contains”, “not_contains”.value: The value to compare against.
- Returns:
- The filtered collection.
-
getInfo
()¶ Returns all the known information about this collection.
This function makes an REST call to to retrieve all the known information about this collection.
- Returns:
- The return contents vary but will include at least:
- features: an array containing metadata about the items in the
- collection that passed all filters.
- properties: a dictionary containing the collection’s metadata
- properties.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
iterate
(algorithm, first=None)¶ Iterates over a collection with an algorithm.
Applies a user-supplied function to each element of a collection. The user-supplied function is given two arguments: the current element, and the value returned by the previous call to iterate() or the first argument, for the first iteration. The result is the value returned by the final call to the user-supplied function.
- Args:
- algorithm: The function to apply to each element. Must take two
- arguments - an element of the collection and the value from the previous iteration.
first: The initial state.
- Returns:
- The result of the Collection.iterate() call.
- Raises:
- ee_exception.EEException: if algorithm is not a function.
-
limit
(maximum, opt_property=None, opt_ascending=None)¶ Limit a collection to the specified number of elements.
This limits a collection to the specified number of elements, optionally sorting them by a specified property first.
- Args:
maximum: The number to limit the collection to. opt_property: The property to sort by, if sorting. opt_ascending: Whether to sort in ascending or descending order.
The default is true (ascending).- Returns:
- The collection.
-
map
(algorithm, opt_dropNulls=None)¶ Maps an algorithm over a collection.
- Args:
- algorithm: The operation to map over the images or features of the
- collection, a Python function that receives an image or features and returns one. The function is called only once and the result is captured as a description, so it cannot perform imperative operations or rely on external state.
- opt_dropNulls: If true, the mapped algorithm is allowed to return nulls,
- and the elements for which it returns nulls will be dropped.
- Returns:
- The mapped collection.
- Raises:
- ee_exception.EEException: if algorithm is not a function.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
Also resets the serial ID used for mapping Python functions to 0.
-
sort
(prop, opt_ascending=None)¶ Sort a collection by the specified property.
- Args:
prop: The property to sort by. opt_ascending: Whether to sort in ascending or descending
order. The default is true (ascending).- Returns:
- The collection.
-
static
ee.computedobject module¶
A representation of an Earth Engine computed object.
-
class
ee.computedobject.
ComputedObject
(func, args, opt_varName=None)¶ Bases:
ee.encodable.Encodable
A representation of an Earth Engine computed object.
This is a base class for most API objects.
The class itself is not abstract as it is used to wrap the return values of algorithms that produce unrecognized types with the minimal functionality necessary to interact well with the rest of the API.
ComputedObjects come in two flavors: 1. If func != null and args != null, the ComputedObject is encoded as an
invocation of func with args.- If func == null and args == null, the ComputedObject is a variable reference. The variable name is stored in its varName member. Note that in this case, varName may still be null; this allows the name to be deterministically generated at a later time. This is used to generate deterministic variable names for mapped functions, ensuring that nested mapping calls do not use the same variable name.
-
aside
(func, *var_args)¶ Calls a function passing this object as the first argument.
Returns the object itself for chaining. Convenient e.g. when debugging:
- c = (ee.ImageCollection(‘foo’).aside(logging.info)
- .filterDate(‘2001-01-01’, ‘2002-01-01’).aside(logging.info) .filterBounds(geom).aside(logging.info) .aside(addToMap, {‘min’: 0, ‘max’: 142}) .select(‘a’, ‘b’))
- Args:
- func: The function to call. *var_args: Any extra arguments to pass to the function.
- Returns:
- The same object, for chaining.
-
encode
(encoder)¶ Encodes the object in a format compatible with Serializer.
-
encode_cloud_value
(encoder)¶ Encodes the object as a ValueNode.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
static
freeze
(obj)¶ Freeze a list or dict so it can be hashed.
-
getInfo
()¶ Fetch and return information about this object.
- Returns:
- The object can evaluate to anything.
-
isVariable
()¶ Returns whether this computed object is a variable reference.
-
classmethod
name
()¶ Returns the name of the object, used in __str__().
-
serialize
(opt_pretty=False, for_cloud_api=False)¶ Serialize this object into a JSON string.
- Args:
opt_pretty: A flag indicating whether to pretty-print the JSON. for_cloud_api: Whether the encoding should be done for the Cloud API
or the legacy API.- Returns:
- The serialized representation of this object.
-
class
ee.computedobject.
ComputedObjectMetaclass
¶ Bases:
type
A meta-class that makes type coercion idempotent.
If an instance of a ComputedObject subclass is instantiated by passing another instance of that class as the sole argument, this short-circuits and returns that argument.
ee.customfunction module¶
An object representing a custom EE Function.
-
class
ee.customfunction.
CustomFunction
(signature, body)¶ Bases:
ee.function.Function
,ee.encodable.Encodable
An object representing a custom EE Function.
-
static
create
(func, return_type, arg_types)¶ Creates a CustomFunction.
The result calls a given native function with the specified return type and argument types and auto-generated argument names.
- Args:
func: The native function to wrap. return_type: The type of the return value, either as a string or a
class reference.- arg_types: The types of the arguments, either as strings or class
- references.
- Returns:
- The constructed CustomFunction.
-
encode
(encoder)¶ Encodes the object in a format compatible with Serializer.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
encode_cloud_invocation
(encoder)¶ Encodes the function as a FunctionInvocation.
- Args:
- encoder: A function that can be called to encode the components of
- an object. Returns a reference to the encoded value.
- Returns:
- The encoded form of the function.
-
encode_cloud_value
(encoder)¶ Encodes the object as a ValueNode.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
encode_invocation
(encoder)¶ Encodes the function in a format compatible with Serializer.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the function.
-
getSignature
()¶ Returns a description of the interface provided by this function.
-
static
variable
(type_name, name)¶ Returns a placeholder variable with a given name and EE type.
- Args:
type_name: A class to mimic. name: The name of the variable as it will appear in the
arguments of the custom functions that use this variable. If null, a name will be auto-generated in _resolveNamelessArgs().- Returns:
- A variable with the given name implementing the given type.
-
static
ee.data module¶
Singleton for the library’s communication with the Earth Engine API.
-
class
ee.data.
TileFetcher
(url_format, map_name=None)¶ Bases:
object
A helper class to fetch image tiles.
-
fetch_tile
(x, y, z)¶ Fetches the map tile specified by (x, y, z).
This method uses any credentials that were specified to ee.Initialize().
- Args:
- x: The tile x coordinate. y: The tile y coordinate. z: The tile zoom level.
- Returns:
- The map tile image data bytes.
- Raises:
- EEException if the fetch fails.
-
format_tile_url
(x, y, z)¶ Generates the URL for a particular tile.
- Args:
- x: The tile x coordinate. y: The tile y coordinate. z: The tile zoom level.
- Returns:
- The tile’s URL.
-
url_format
¶ Gets the URL format for this tile fetcher.
- Returns:
- A format string with {x}, {y}, and {z} placeholders. If you are using the Cloud API, and have not provided an API key, then this URL will require authorization. Use the credentials provided to ee.Initialize() to provide this authorization. Alternatively, use “fetch_tile” to fetch the tile data, which will handle the authorization for you.
-
-
ee.data.
cancelOperation
(operation_name)¶
-
ee.data.
cancelTask
(taskId)¶ Cancels a batch task. DEPRECATED: Use cancelOperation
-
ee.data.
computeValue
(obj)¶ Sends a request to compute a value.
- Args:
- obj: A ComputedObject whose value is desired.
- Returns:
- The result of evaluating that object on the server.
-
ee.data.
convert_asset_id_to_asset_name
(asset_id)¶ Converts an internal asset ID to a Cloud API asset name.
If asset_id already matches the format ‘projects//assets/*’, it is returned as-is.
- Args:
- asset_id: The asset ID to convert.
- Returns:
- An asset name string in the format ‘projects//assets/*’.
-
ee.data.
copyAsset
(sourceId, destinationId, allowOverwrite=False)¶ Copies the asset from sourceId into destinationId.
- Args:
- sourceId: The ID of the asset to copy. destinationId: The ID of the new asset created by copying. allowOverwrite: If True, allows overwriting an existing asset.
-
ee.data.
createAsset
(value, opt_path=None, opt_force=False, opt_properties=None)¶ Creates an asset from a JSON value.
To create an empty image collection or folder, pass in a “value” object with a “type” key whose value is “ImageCollection” or “Folder”. If you are using the Cloud API, use “IMAGE_COLLECTION” or “FOLDER”.
- Args:
- value: An object describing the asset to create or a JSON string
- with the already-serialized value for the new asset.
opt_path: An optional desired ID, including full path. opt_force: True if asset overwrite is allowed opt_properties: The keys and values of the properties to set
on the created asset.- Returns:
- A description of the saved asset, including a generated ID.
-
ee.data.
createAssetHome
(requestedId)¶ Attempts to create a home root folder for the current user (“users/joe”).
Results in an error if the user already has a home root folder or the requested ID is unavailable.
- Args:
- requestedId: The requested ID of the home folder (e.g. “users/joe”).
-
ee.data.
create_assets
(asset_ids, asset_type, mk_parents)¶ Creates the specified assets if they do not exist.
-
ee.data.
deleteAsset
(assetId)¶ Deletes the asset with the given id.
- Args:
- assetId: The ID of the asset to delete.
-
ee.data.
exportImage
(request_id, params)¶ Starts an image export task running.
- Args:
- request_id (string): A unique ID for the task, from newTaskId.
- If you are using the cloud API, this does not need to be from newTaskId, (though that’s a good idea, as it’s a good source of unique strings). It can also be empty, but in that case the request is more likely to fail as it cannot be safely retried.
- params: The object that describes the export task.
- If you are using the cloud API, this should be an ExportImageRequest. However, the “expression” parameter can be the actual Image to be exported, not its serialized form.
- Returns:
- A dict with information about the created task. If you are using the cloud API, this will be an Operation.
-
ee.data.
exportMap
(request_id, params)¶ Starts a map export task running.
- Args:
- request_id (string): A unique ID for the task, from newTaskId.
- If you are using the cloud API, this does not need to be from newTaskId, (though that’s a good idea, as it’s a good source of unique strings). It can also be empty, but in that case the request is more likely to fail as it cannot be safely retried.
- params: The object that describes the export task.
- If you are using the cloud API, this should be an ExportMapRequest. However, the “expression” parameter can be the actual Image to be exported, not its serialized form.
- Returns:
- A dict with information about the created task. If you are using the cloud API, this will be an Operation.
-
ee.data.
exportTable
(request_id, params)¶ Starts a table export task running.
- Args:
- request_id (string): A unique ID for the task, from newTaskId.
- If you are using the cloud API, this does not need to be from newTaskId, (though that’s a good idea, as it’s a good source of unique strings). It can also be empty, but in that case the request is more likely to fail as it cannot be safely retried.
- params: The object that describes the export task.
- If you are using the cloud API, this should be an ExportTableRequest. However, the “expression” parameter can be the actual FeatureCollection to be exported, not its serialized form.
- Returns:
- A dict with information about the created task. If you are using the cloud API, this will be an Operation.
-
ee.data.
exportVideo
(request_id, params)¶ Starts a video export task running.
- Args:
- request_id (string): A unique ID for the task, from newTaskId.
- If you are using the cloud API, this does not need to be from newTaskId, (though that’s a good idea, as it’s a good source of unique strings). It can also be empty, but in that case the request is more likely to fail as it cannot be safely retried.
- params: The object that describes the export task.
- If you are using the cloud API, this should be an ExportVideoRequest. However, the “expression” parameter can be the actual ImageCollection to be exported, not its serialized form.
- Returns:
- A dict with information about the created task. If you are using the cloud API, this will be an Operation.
-
ee.data.
getAlgorithms
()¶ Get the list of algorithms.
- Returns:
The dictionary of algorithms. Each algorithm is a dictionary containing the following fields:
“description” - (string) A text description of the algorithm. “returns” - (string) The return type of the algorithm. “args” - An array of arguments. Each argument specifies the following:
“name” - (string) The name of the argument. “description” - (string) A text description of the argument. “type” - (string) The type of the argument. “optional” - (boolean) Whether the argument is optional or not. “default” - A representation of the default value if the argument
is not specified.
-
ee.data.
getAsset
(asset_id)¶ Loads info for an asset, given an asset id.
- Args:
- asset_id: The asset to be retrieved.
- Returns:
- The asset’s information, as an EarthEngineAsset.
-
ee.data.
getAssetAcl
(assetId)¶ Returns the access control list of the asset with the given ID.
- Args:
- assetId: The ID of the asset to check.
- Returns:
- A dict describing the asset’s ACL. Looks like:
- {
- “owners” : [“user@domain1.com”], “writers”: [“user2@domain1.com”, “user3@domain1.com”], “readers”: [“some_group@domain2.com”], “all_users_can_read” : True
}
If you are using the cloud API, then the entities in the ACL will be prefixed by a type tag, such as “user:” or “group:”.
DEPRECATED: Use getIamPolicy
-
ee.data.
getAssetRootQuota
(rootId)¶ Returns quota usage details for the asset root with the given ID.
Usage notes:
- The id must be a root folder like “users/foo” (not “users/foo/bar”).
- The authenticated user must own the asset root to see its quota usage.
- Args:
- rootId: The ID of the asset to check.
- Returns:
- A dict describing the asset’s quota usage. Looks like, with size in bytes:
- {
- asset_count: {usage: number, limit: number}, asset_size: {usage: number, limit: number},
}
-
ee.data.
getAssetRoots
()¶ Returns the list of the root folders the user owns.
- Note: The “id” values for roots are two levels deep, e.g. “users/johndoe”
- not “users/johndoe/notaroot”.
- Returns:
- A list of folder descriptions formatted like:
- [
- {“type”: “Folder”, “id”: “users/foo”}, {“type”: “Folder”, “id”: “projects/bar”},
]
-
ee.data.
getDownloadId
(params)¶ Get a Download ID.
- Args:
- params: An object containing visualization options with the following
- possible values:
name - a base name to use when constructing filenames. bands - a description of the bands to download. Must be an array of
dictionaries, each with the following keys:id - the name of the band, a string, required. crs - an optional CRS string defining the band projection. crs_transform - an optional array of 6 numbers specifying an affine
transform from the specified CRS, in the order: xScale, yShearing, xShearing, yScale, xTranslation and yTranslation.- dimensions - an optional array of two integers defining the width and
- height to which the band is cropped.
- scale - an optional number, specifying the scale in meters of the
- band; ignored if crs and crs_transform is specified.
- crs - a default CRS string to use for any bands that do not explicitly
- specify one.
- crs_transform - a default affine transform to use for any bands that do
- not specify one, of the same format as the crs_transform of bands.
- dimensions - default image cropping dimensions to use for any bands
- that do not specify them.
- scale - a default scale to use for any bands that do not specify one;
- ignored if crs and crs_transform is specified.
- region - a polygon specifying a region to download; ignored if crs
- and crs_transform is specified.
- Returns:
- A dict containing a docid and token.
DEPRECATED: Use getThumbId
-
ee.data.
getIamPolicy
(asset_id)¶ Loads ACL info for an asset, given an asset id.
- Args:
- asset_id: The asset to be retrieved.
- Returns:
- The asset’s ACL, as an IAM Policy.
-
ee.data.
getInfo
(asset_id)¶ Load info for an asset, given an asset id.
- Args:
- asset_id: The asset to be retrieved.
- Returns:
- The value call results, or None if the asset does not exist.
DEPRECATED: Use getAsset
-
ee.data.
getList
(params)¶ Get a list of contents for a collection asset.
- Args:
- params: An object containing request parameters with the
- following possible values:
- id (string) The asset id of the collection to list. starttime (number) Start time, in msec since the epoch. endtime (number) End time, in msec since the epoch. fields (comma-separated strings) Field names to return.
- Returns:
- The list call results.
DEPRECATED: Use listAssets or listImages
-
ee.data.
getMapId
(params)¶ Get a Map ID for a given asset.
- Args:
- params: An object containing visualization options with the
- following possible values:
- image - The image to render, as an Image or a JSON string.
- The JSON string format is deprecated.
version - (number) Version number of image (or latest). bands - (comma-separated strings) Comma-delimited list of
band names to be mapped to RGB.- min - (comma-separated numbers) Value (or one per band)
- to map onto 00.
- max - (comma-separated numbers) Value (or one per band)
- to map onto FF.
- gain - (comma-separated numbers) Gain (or one per band)
- to map onto 00-FF.
- bias - (comma-separated numbers) Offset (or one per band)
- to map onto 00-FF.
- gamma - (comma-separated numbers) Gamma correction
- factor (or one per band).
- palette - (comma-separated strings) A string of comma-separated
- CSS-style color strings (single-band previews only). For example, ‘FF0000,000000’.
- format - (string) The desired map tile image format. If omitted, one is
- chosen automatically. Can be ‘jpg’ (does not support transparency) or ‘png’ (supports transparency).
- Returns:
A dictionary containing: - “mapid” and “token” strings: these identify the map. - “tile_fetcher”: a TileFetcher which can be used to fetch the tile
images, or to get a format for the tile URLs.
-
ee.data.
getOperation
(operation_name)¶ Retrieves the status of a long-running operation.
- Args:
- operation_name: The name of the operation to retrieve, in the format
- operations/AAAABBBBCCCCDDDDEEEEFFFF.
- Returns:
- An Operation status dictionary for the requested operation.
-
ee.data.
getTableDownloadId
(params)¶ Get a Download ID.
- Args:
- params: An object containing table download options with the following
- possible values:
format - The download format, CSV or JSON. selectors - Comma separated string of selectors that can be used to
determine which attributes will be downloaded.filename - The name of the file that will be downloaded.
- Returns:
- A dict containing a docid and token.
-
ee.data.
getTaskList
()¶ Retrieves a list of the user’s tasks.
- Returns:
- A list of task status dictionaries, one for each task submitted to EE by the current user. These include currently running tasks as well as recently canceled or failed tasks.
DEPRECATED: Use listOperations
-
ee.data.
getTaskStatus
(taskId)¶ Retrieve status of one or more long-running tasks.
- Args:
- taskId: ID of the task or a list of multiple IDs.
- Returns:
List containing one object for each queried task, in the same order as the input array, each object containing the following values:
id (string) ID of the task. state (string) State of the task, one of READY, RUNNING, COMPLETED,
FAILED, CANCELLED; or UNKNOWN if the task with the specified ID doesn’t exist.error_message (string) For a FAILED task, a description of the error.
DEPRECATED: Use getOperation
-
ee.data.
getThumbId
(params)¶ Get a Thumbnail ID for a given asset.
- Args:
- params: Parameters identical to getMapId, plus:
- size - (a number or pair of numbers in format WIDTHxHEIGHT) Maximum
- dimensions of the thumbnail to render, in pixels. If only one number is passed, it is used as the maximum, and the other dimension is computed by proportional scaling.
- region - (E,S,W,N or GeoJSON) Geospatial region of the image
- to render. By default, the whole image.
format - (string) Either ‘png’ (default) or ‘jpg’.
- Returns:
- A dictionary containing “thumbid” and “token” strings, which identify the thumbnail.
-
ee.data.
getThumbnail
(params)¶ Get a Thumbnail for a given asset.
- Args:
- params: Parameters identical to getMapId, plus:
- size - (a number or pair of numbers in format WIDTHxHEIGHT) Maximum
- dimensions of the thumbnail to render, in pixels. If only one number is passed, it is used as the maximum, and the other dimension is computed by proportional scaling.
- region - (E,S,W,N or GeoJSON) Geospatial region of the image
- to render. By default, the whole image.
format - (string) Either ‘png’ (default) or ‘jpg’.
- Returns:
- A thumbnail image as raw PNG data.
DEPRECATED: Use getThumbId and makeThumbUrl
-
ee.data.
getTileUrl
(mapid, x, y, z)¶ Generate a URL for map tiles from a Map ID and coordinates.
- Args:
- mapid: The Map ID to generate tiles for, a dictionary returned
- by getMapId.
x: The tile x coordinate. y: The tile y coordinate. z: The tile zoom level.
- Returns:
- The tile URL.
-
ee.data.
getValue
(params)¶ Retrieve a processed value from the front end.
- Args:
- params: A dictionary containing:
- json - (String) A JSON object to be evaluated.
- Returns:
- The value call results.
DEPRECATED: Use computeValue
-
ee.data.
initialize
(credentials=None, api_base_url=None, tile_base_url=None, use_cloud_api=None, cloud_api_base_url=None, cloud_api_key=None, project=None, http_transport=None)¶ Initializes the data module, setting credentials and base URLs.
If any of the arguments are unspecified, they will keep their old values; the defaults if initialize() has never been called before.
At least one of “credentials” and “cloud_api_key” must be provided. If both are provided, both will be used; in this case, the API key’s project must match the credentials’ project.
- Args:
credentials: The OAuth2 credentials. api_base_url: The EarthEngine REST API endpoint. tile_base_url: The EarthEngine REST tile endpoint. use_cloud_api: Whether to use the EarthEngine Cloud API rather than the
older REST API.cloud_api_base_url: The EarthEngine Cloud API endpoint. cloud_api_key: The API key to use with the Cloud API. project: The default cloud project associated with the user. http_transport: The http transport to use
-
ee.data.
listAssets
(params)¶
-
ee.data.
listBuckets
(project=None)¶
-
ee.data.
listImages
(params)¶
-
ee.data.
listOperations
(project=None)¶ Retrieves a list of the user’s tasks.
- Args:
- project: The project to list operations for, uses the default set project
- if none is provided.
- Returns:
- A list of Operation status dictionaries, one for each task submitted to EE by the current user. These include currently running tasks as well as recently canceled or failed tasks.
-
ee.data.
makeDownloadUrl
(downloadId)¶ Create a download URL from the given docid and token.
- Args:
- downloadId: An object containing a download docid and token.
- Returns:
- A URL from which the download can be obtained.
DEPRECATED: Use getThumbId and makeThumbUrl
-
ee.data.
makeTableDownloadUrl
(downloadId)¶ Create a table download URL from a docid and token.
- Args:
- downloadId: A table download id and token.
- Returns:
- A Url from which the download can be obtained.
-
ee.data.
makeThumbUrl
(thumbId)¶ Create a thumbnail URL from the given thumbid and token.
- Args:
- thumbId: An object containing a thumbnail thumbid and token.
- Returns:
- A URL from which the thumbnail can be obtained.
-
ee.data.
newTaskId
(count=1)¶ Generate an ID for a long-running task.
- Args:
- count: Optional count of IDs to generate, one by default.
- Returns:
- A list containing generated ID strings.
-
ee.data.
profiling
(hook)¶ Returns a context manager which enables or disables profiling.
If hook is not None, enables profiling for all API calls in its scope and calls the hook function with all resulting profile IDs. If hook is null, disables profiling (or leaves it disabled).
- Args:
- hook: A function of one argument which is called with each profile
- ID obtained from API calls, just before the API call returns.
-
ee.data.
renameAsset
(sourceId, destinationId)¶ Renames the asset from sourceId to destinationId.
- Args:
- sourceId: The ID of the asset to rename. destinationId: The new ID of the asset.
-
ee.data.
reset
()¶ Resets the data module, clearing credentials and custom base URLs.
-
ee.data.
send_
(path, params, opt_method='POST', opt_raw=False)¶ Send an API call.
- Args:
path: The API endpoint to call, or a full URL. params: The call parameters. opt_method: The HTTPRequest method (GET or POST). opt_raw: Whether the data should be returned raw, without attempting
to decode it as JSON.- Returns:
- The data object returned by the API call.
- Raises:
- EEException: For malformed requests or errors from the server.
-
ee.data.
setAssetAcl
(assetId, aclUpdate)¶ Sets the access control list of the asset with the given ID.
The owner ACL cannot be changed, and the final ACL of the asset is constructed by merging the OWNER entries of the old ACL with the incoming ACL record.
- Args:
assetId: The ID of the asset to set the ACL on. aclUpdate: The updated ACL for the asset. Must be formatted like the
value returned by getAssetAcl but without “owners”.
DEPRECATED: Use setIamPolicy
-
ee.data.
setAssetProperties
(assetId, properties)¶ Sets metadata properties of the asset with the given ID.
To delete a property, set its value to None. The authenticated user must be a writer or owner of the asset.
- Args:
- assetId: The ID of the asset to set the ACL on. properties: A dictionary of keys and values for the properties to update.
DEPRECATED: Use updateAsset
-
ee.data.
setCloudApiKey
(cloud_api_key)¶ Sets the Cloud API key parameter (“api_key”) for all requests.
-
ee.data.
setCloudApiUserProject
(cloud_api_user_project)¶
-
ee.data.
setDeadline
(milliseconds)¶ Sets the timeout length for API requests.
- Args:
- milliseconds: The number of milliseconds to wait for a request
- before considering it timed out. 0 means no limit.
-
ee.data.
setIamPolicy
(asset_id, policy)¶ Sets ACL info for an asset.
- Args:
asset_id: The asset to set the ACL policy on. policy: The new Policy to apply to the asset. This replaces
the current Policy.- Returns:
- The new ACL, as an IAM Policy.
-
ee.data.
startIngestion
(request_id, params, allow_overwrite=False)¶ Creates an image asset import task.
- Args:
- request_id (string): A unique ID for the ingestion, from newTaskId.
- If you are using the Cloud API, this does not need to be from newTaskId, (though that’s a good idea, as it’s a good source of unique strings). It can also be empty, but in that case the request is more likely to fail as it cannot be safely retried.
- params: The object that describes the import task, which can
- have these fields:
id (string) The destination asset id (e.g. users/foo/bar). tilesets (array) A list of Google Cloud Storage source file paths
- formatted like:
- [{‘sources’: [
- {‘primaryPath’: ‘foo.tif’, ‘additionalPaths’: [‘foo.prj’]}, {‘primaryPath’: ‘bar.tif’, ‘additionalPaths’: [‘bar.prj’},
]}]
Where path values correspond to source files’ Google Cloud Storage object names, e.g. ‘gs://bucketname/filename.tif’
- bands (array) An optional list of band names formatted like:
- [{‘id’: ‘R’}, {‘id’: ‘G’}, {‘id’: ‘B’}]
If you are using the Cloud API, this object must instead be a dict representation of an ImageManifest.
- allow_overwrite: Whether the ingested image can overwrite an
- existing version.
- Returns:
- A dict with notes about the created task. This will include the ID for the import task (under ‘id’), which may be different from request_id.
-
ee.data.
startProcessing
(taskId, params)¶ Create processing task that exports or pre-renders an image.
- Args:
taskId: ID for the task (obtained using newTaskId). params: The object that describes the processing task; only fields
- that are common for all processing types are documented below.
- type (string) Either ‘EXPORT_IMAGE’, ‘EXPORT_FEATURES’,
- ‘EXPORT_VIDEO’ or ‘EXPORT_TILES’.
json (string) JSON description of the image.
- Returns:
- A dict with optional notes about the created task.
DEPRECATED: Use one of the export* functions
-
ee.data.
startTableIngestion
(request_id, params, allow_overwrite=False)¶ Creates a table asset import task.
- Args:
- request_id (string): A unique ID for the ingestion, from newTaskId.
- If you are using the Cloud API, this does not need to be from newTaskId, (though that’s a good idea, as it’s a good source of unique strings). It can also be empty, but in that case the request is more likely to fail as it cannot be safely retried.
- params: The object that describes the import task, which can
- have these fields:
id (string) The destination asset id (e.g. users/foo/bar). sources (array) A list of CNS source file paths with optional
character encoding formatted like: “sources”: [{ “primaryPath”: “states.shp”, “charset”: “UTF-8” }] Where path values correspond to source files’ CNS locations, e.g. ‘googlefile://namespace/foobar.shp’, and ‘charset’ refers to the character encoding of the source file.
If you are using the Cloud API, this object must instead be a dict representation of a TableManifest.
- allow_overwrite: Whether the ingested image can overwrite an
- existing version.
- Returns:
- A dict with notes about the created task. This will include the ID for the import task (under ‘id’), which may be different from request_id.
-
ee.data.
updateAsset
(asset_id, asset, update_mask)¶ Updates an asset.
- Args:
asset_id: The ID of the asset to update. asset: The updated version of the asset, containing only the new values of
the fields to be updated. Only the “start_time”, “end_time”, and “properties” fields can be updated. If a value is named in “update_mask”, but is unset in “asset”, then that value will be deleted from the asset.- update_mask: A list of the values to update. This should contain the strings
- “start_time” or “end_time” to update the corresponding timestamp. If a property is to be updated or deleted, it should be named here as “properties.THAT_PROPERTY_NAME”. If the entire property set is to be replaced, this should contain the string “properties”. If this list is empty, all properties and both timestamps will be updated.
ee.deprecation module¶
Decorators to mark function deprecated.
-
ee.deprecation.
CanUseDeprecated
(func)¶ Ignores deprecation warnings emitted while the decorated function runs.
-
ee.deprecation.
Deprecated
(message)¶ Returns a decorator with a given warning message.
ee.deserializer module¶
A deserializer that decodes EE object trees from JSON DAGs.
-
ee.deserializer.
decode
(json_obj)¶ Decodes an object previously encoded using the EE API v2 (DAG) format.
- Args:
- json_obj: The serialied object to decode.
- Returns:
- The decoded object.
-
ee.deserializer.
fromJSON
(json_obj)¶ Deserialize an object from a JSON string appropriate for API calls.
- Args:
- json_obj: The JSON represenation of the input.
- Returns:
- The deserialized object.
ee.dictionary module¶
A wrapper for dictionaries.
-
class
ee.dictionary.
Dictionary
(arg=None)¶ Bases:
ee.computedobject.ComputedObject
An object to represent dictionaries.
-
encode
(opt_encoder=None)¶ Encodes the object in a format compatible with Serializer.
-
encode_cloud_value
(opt_encoder=None)¶ Encodes the object as a ValueNode.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
ee.ee_date module¶
A wrapper for dates.
-
class
ee.ee_date.
Date
(date, opt_tz=None)¶ Bases:
ee.computedobject.ComputedObject
An object to represent dates.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
classmethod
ee.ee_exception module¶
A simple exception for the EE library.
-
exception
ee.ee_exception.
EEException
¶ Bases:
Exception
A simple exception for the EE library.
ee.ee_list module¶
A wrapper for lists.
-
class
ee.ee_list.
List
(arg)¶ Bases:
ee.computedobject.ComputedObject
An object to represent lists.
-
encode
(opt_encoder=None)¶ Encodes the object in a format compatible with Serializer.
-
encode_cloud_value
(opt_encoder=None)¶ Encodes the object as a ValueNode.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
ee.ee_number module¶
A wrapper for numbers.
-
class
ee.ee_number.
Number
(number)¶ Bases:
ee.computedobject.ComputedObject
An object to represent numbers.
-
encode
(opt_encoder=None)¶ Encodes the object in a format compatible with Serializer.
-
encode_cloud_value
(opt_encoder=None)¶ Encodes the object as a ValueNode.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
ee.ee_string module¶
A wrapper for strings.
-
class
ee.ee_string.
String
(string)¶ Bases:
ee.computedobject.ComputedObject
An object to represent strings.
-
encode
(opt_encoder=None)¶ Encodes the object in a format compatible with Serializer.
-
encode_cloud_value
(opt_encoder=None)¶ Encodes the object as a ValueNode.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
ee.ee_types module¶
A set of utilities to work with EE types.
-
ee.ee_types.
classToName
(klass)¶ Converts a class to the API-friendly type name.
- Args:
- klass: The class.
- Returns:
- The name of the class, or “Object” if not recognized.
-
ee.ee_types.
isArray
(obj)¶ Returns true if this object is an array or array variable.
- Args:
- obj: The object to check.
- Returns:
- Whether the object is an array or array variable.
-
ee.ee_types.
isNumber
(obj)¶ Returns true if this object is a number or number variable.
- Args:
- obj: The object to check.
- Returns:
- Whether the object is a number or number variable.
-
ee.ee_types.
isString
(obj)¶ Returns true if this object is a string or string variable.
- Args:
- obj: The object to check.
- Returns:
- Whether the object is a string or string variable.
-
ee.ee_types.
isSubtype
(firstType, secondType)¶ Checks whether a type is a subtype of another.
- Args:
- firstType: The first type name. secondType: The second type name.
- Returns:
- Whether secondType is a subtype of firstType.
-
ee.ee_types.
nameToClass
(name)¶ Converts a class name to a class. Returns None if not an ee class.
- Args:
- name: The class name.
- Returns:
- The named class.
ee.element module¶
Base class for Image, Feature and Collection.
This class is never intended to be instantiated by the user.
-
class
ee.element.
Element
(func, args, opt_varName=None)¶ Bases:
ee.computedobject.ComputedObject
Base class for ImageCollection and FeatureCollection.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
classmethod
ee.encodable module¶
Interfaces implemented by serializable objects.
-
class
ee.encodable.
Encodable
¶ Bases:
object
An interface implemented by objects that can serialize themselves.
-
encode
(encoder)¶ Encodes the object in a format compatible with Serializer.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
encode_cloud_value
(encoder)¶ Encodes the object as a ValueNode.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the object.
-
-
class
ee.encodable.
EncodableFunction
¶ Bases:
object
An interface implemented by functions that can serialize themselves.
-
encode_cloud_invocation
(encoder)¶ Encodes the function as a FunctionInvocation.
- Args:
- encoder: A function that can be called to encode the components of
- an object. Returns a reference to the encoded value.
- Returns:
- The encoded form of the function.
-
encode_invocation
(encoder)¶ Encodes the function in a format compatible with Serializer.
- Args:
- encoder: A function that can be called to encode the components of
- an object.
- Returns:
- The encoded form of the function.
-
ee.feature module¶
An object representing EE Features.
-
class
ee.feature.
Feature
(geom, opt_properties=None)¶ Bases:
ee.element.Element
An object representing EE Features.
-
getMapId
(vis_params=None)¶ Fetch and return a map id and token, suitable for use in a Map overlay.
- Args:
- vis_params: The visualization parameters. Currently only one parameter,
- ‘color’, containing a hex RGB color string is allowed.
- Returns:
- An object containing a mapid string, an access token, plus a Collection.draw image wrapping a FeatureCollection containing this feature.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
ee.featurecollection module¶
Representation of an Earth Engine FeatureCollection.
-
class
ee.featurecollection.
FeatureCollection
(args, opt_column=None)¶ Bases:
ee.collection.Collection
A representation of a FeatureCollection.
-
static
elementType
()¶ Returns the type of the collection’s elements.
-
getDownloadURL
(filetype=None, selectors=None, filename=None)¶ Get a download URL for this feature collection.
- Args:
filetype: The filetype of download, either CSV or JSON. Defaults to CSV. selectors: The selectors that should be used to determine which attributes
will be downloaded.filename: The name of the file to be downloaded.
- Returns:
- A URL to download the specified feature collection.
-
getDownloadUrl
(filetype=None, selectors=None, filename=None)¶ Get a download URL for this feature collection.
- Args:
filetype: The filetype of download, either CSV or JSON. Defaults to CSV. selectors: The selectors that should be used to determine which attributes
will be downloaded.filename: The name of the file to be downloaded.
- Returns:
- A URL to download the specified feature collection.
DEPRECATED: Use getDownloadURL().
-
getMapId
(vis_params=None)¶ Fetch and return a map id and token, suitable for use in a Map overlay.
- Args:
- vis_params: The visualization parameters. Currently only one parameter,
- ‘color’, containing a hex RGB color string is allowed.
- Returns:
- An object containing a mapid string, an access token, plus a Collection.draw image wrapping this collection.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
select
(propertySelectors, newProperties=None, retainGeometry=True, *args)¶ Select properties from each feature in a collection.
- Args:
- propertySelectors: An array of names or regexes specifying the properties
- to select.
- newProperties: An array of strings specifying the new names for the
- selected properties. If supplied, the length must match the number of properties selected.
retainGeometry: A boolean. When false, the result will have no geometry. *args: Selector elements as varargs.
- Returns:
- The feature collection with selected properties.
-
static
ee.filter module¶
Collection filters.
- Example usage:
- Filter(‘time’, low, high)
- .bounds(ring) .eq(‘time’, value) .lt(‘time’, value)
-
class
ee.filter.
Filter
(opt_filter=None)¶ Bases:
ee.computedobject.ComputedObject
An object to represent collection filters.
-
static
And
(*args)¶ Combine two or more filters using boolean AND.
-
Not
()¶ Returns the opposite of this filter.
- Returns:
- The negated filter, which will match iff this filter doesn’t.
-
static
Or
(*args)¶ Combine two or more filters using boolean OR.
-
static
date
(start, opt_end=None)¶ Filter images by date.
The start and end may be a Date, numbers (interpreted as milliseconds since 1970-01-01T00:00:00Z), or strings (such as ‘1996-01-01T08:00’).
- Args:
start: The inclusive start date. opt_end: The optional exclusive end date, If not specified, a
1-millisecond range starting at ‘start’ is created.- Returns:
- The modified filter.
-
static
eq
(name, value)¶ Filter to metadata equal to the given value.
-
static
geometry
(geometry, opt_errorMargin=None)¶ Filter on bounds.
Items in the collection with a footprint that fails to intersect the bounds will be excluded when the collection is evaluated.
- Args:
- geometry: The geometry to filter to either as a GeoJSON geometry,
- or a FeatureCollection, from which a geometry will be extracted.
- opt_errorMargin: An optional error margin. If a number, interpreted as
- sphere surface meters.
- Returns:
- The modified filter.
-
static
gt
(name, value)¶ Filter on metadata greater than the given value.
-
static
gte
(name, value)¶ Filter on metadata greater than or equal to the given value.
-
static
inList
(opt_leftField=None, opt_rightValue=None, opt_rightField=None, opt_leftValue=None)¶ Filter on metadata contained in a list.
- Args:
- opt_leftField: A selector for the left operand.
- Should not be specified if leftValue is specified.
- opt_rightValue: The value of the right operand.
- Should not be specified if rightField is specified.
- opt_rightField: A selector for the right operand.
- Should not be specified if rightValue is specified.
- opt_leftValue: The value of the left operand.
- Should not be specified if leftField is specified.
- Returns:
- The constructed filter.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
lt
(name, value)¶ Filter to metadata less than the given value.
-
static
lte
(name, value)¶ Filter on metadata less than or equal to the given value.
-
static
metadata_
(name, operator, value)¶ Filter on metadata. This is deprecated.
- Args:
name: The property name to filter on. operator: The type of comparison. One of:
“equals”, “less_than”, “greater_than”, “contains”, “begins_with”, “ends_with”, or any of these prefixed with “not_”.value: The value to compare against.
- Returns:
- The new filter.
Deprecated. Use ee.Filter.eq(), ee.Filter.gte(), etc.’
-
static
name
()¶ Returns the name of the object, used in __str__().
-
static
neq
(name, value)¶ Filter to metadata not equal to the given value.
-
predicateCount
()¶ Return the number of predicates that have been added to this filter.
- Returns:
- The number of predicates that have been added to this filter. This does not count nested predicates.
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
static
ee.function module¶
A base class for EE Functions.
-
class
ee.function.
Function
¶ Bases:
ee.encodable.EncodableFunction
An abstract base class for functions callable by the EE API.
Subclasses must implement encode_invocation() and getSignature().
-
apply
(named_args)¶ Calls the function with a dictionary of named arguments.
- Args:
- named_args: A dictionary of named arguments to pass to the function.
- Returns:
- A ComputedObject representing the called function. If the signature specifies a recognized return type, the returned value will be cast to that type.
-
call
(*args, **kwargs)¶ Calls the function with the given positional and keyword arguments.
-
getReturnType
()¶
-
getSignature
()¶ Returns a description of the interface provided by this function.
- Returns:
- The function’s signature, a dictionary containing:
name: string returns: type name string args: list of argument dictionaries, each containing:
name: string type: type name string optional: boolean default: an arbitrary primitive or encodable object
-
nameArgs
(args, extra_keyword_args=None)¶ Converts a list of positional arguments to a map of keyword arguments.
Uses the function’s signature for argument names. Note that this does not check whether the array contains enough arguments to satisfy the call.
- Args:
- args: Positional arguments to the function. extra_keyword_args: Optional named arguments to add.
- Returns:
- Keyword arguments to the function.
- Raises:
- EEException: If conflicting arguments or too many of them are supplied.
-
promoteArgs
(args)¶ Promotes arguments to their types based on the function’s signature.
Verifies that all required arguments are provided and no unknown arguments are present.
- Args:
- args: A dictionary of keyword arguments to the function.
- Returns:
- A dictionary of promoted arguments.
- Raises:
- EEException: If unrecognized arguments are passed or required ones are
- missing.
-
serialize
(for_cloud_api=False)¶
-
ee.geometry module¶
An object representing EE Geometries.
-
class
ee.geometry.
Geometry
(geo_json, opt_proj=None, opt_geodesic=None, opt_evenOdd=None)¶ Bases:
ee.computedobject.ComputedObject
An Earth Engine geometry.
-
static
LineString
(coords=<object object>, proj=<object object>, geodesic=<object object>, maxError=<object object>, *args)¶ Constructs an ee.Geometry describing a LineString.
- Args:
- coords: A list of at least two points. May be a list of coordinates in
- the GeoJSON ‘LineString’ format, a list of at least two ee.Geometry describing a point, or a list of at least four numbers defining the [x,y] coordinates of at least two points.
- proj: The projection of this geometry. If unspecified, the default is the
- projection of the input ee.Geometry, or EPSG:4326 if there are no ee.Geometry inputs.
- geodesic: If false, edges are straight in the projection. If true, edges
- are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers.
- maxError: Max error when input geometry must be reprojected to an
- explicitly requested result projection or geodesic state.
- *args: For convenience, varargs may be used when all arguments are
- numbers. This allows creating geodesic EPSG:4326 LineStrings given an even number of arguments, e.g. ee.Geometry.LineString(aLng, aLat, bLng, bLat, …).
- Returns:
- An ee.Geometry describing a LineString.
-
static
LinearRing
(coords=<object object>, proj=<object object>, geodesic=<object object>, maxError=<object object>, *args)¶ Constructs an ee.Geometry describing a LinearRing.
If the last point is not equal to the first, a duplicate of the first point will be added at the end.
- Args:
- coords: A list of points in the ring. May be a list of coordinates in
- the GeoJSON ‘LinearRing’ format, a list of at least three ee.Geometry describing a point, or a list of at least six numbers defining the [x,y] coordinates of at least three points.
- proj: The projection of this geometry. If unspecified, the default is the
- projection of the input ee.Geometry, or EPSG:4326 if there are no ee.Geometry inputs.
- geodesic: If false, edges are straight in the projection. If true, edges
- are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers.
- maxError: Max error when input geometry must be reprojected to an
- explicitly requested result projection or geodesic state.
- *args: For convenience, varargs may be used when all arguments are
- numbers. This allows creating geodesic EPSG:4326 LinearRings given an even number of arguments, e.g. ee.Geometry.LinearRing(aLng, aLat, bLng, bLat, …).
- Returns:
- A dictionary representing a GeoJSON LinearRing.
-
static
MultiLineString
(coords=<object object>, proj=<object object>, geodesic=<object object>, maxError=<object object>, *args)¶ Constructs an ee.Geometry describing a MultiLineString.
Create a GeoJSON MultiLineString from either a list of points, or an array of lines (each an array of Points). If a list of points is specified, only a single line is created.
- Args:
- coords: A list of linestrings. May be a list of coordinates in the
- GeoJSON ‘MultiLineString’ format, a list of at least two ee.Geometry describing a LineString, or a list of number defining a single linestring.
- proj: The projection of this geometry. If unspecified, the default is the
- projection of the input ee.Geometry, or EPSG:4326 if there are no ee.Geometry inputs.
- geodesic: If false, edges are straight in the projection. If true, edges
- are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers.
- maxError: Max error when input geometry must be reprojected to an
- explicitly requested result projection or geodesic state.
- *args: For convenience, varargs may be used when all arguments are
- numbers. This allows creating geodesic EPSG:4326 MultiLineStrings with a single LineString, given an even number of arguments, e.g. ee.Geometry.MultiLineString(aLng, aLat, bLng, bLat, …).
- Returns:
- An ee.Geometry describing a MultiLineString.
-
static
MultiPoint
(coords=<object object>, proj=<object object>, *args)¶ Constructs an ee.Geometry describing a MultiPoint.
- Args:
- coords: A list of points, each in the GeoJSON ‘coordinates’ format of a
- Point, or a list of the x,y coordinates in the given projection, or an ee.Geometry describing a point.
- proj: The projection of this geometry. If unspecified, the default is
- the projection of the input ee.Geometry, or EPSG:4326 if there are no ee.Geometry inputs.
- *args: For convenience, varargs may be used when all arguments are
- numbers. This allows creating EPSG:4326 MultiPoints given an even number of arguments, e.g. ee.Geometry.MultiPoint(aLng, aLat, bLng, bLat, …).
- Returns:
- An ee.Geometry describing a MultiPoint.
-
static
MultiPolygon
(coords=<object object>, proj=<object object>, geodesic=<object object>, maxError=<object object>, evenOdd=<object object>, *args)¶ Constructs an ee.Geometry describing a MultiPolygon.
If created from points, only one polygon can be specified.
- Args:
- coords: A list of polygons. May be a list of coordinates in the GeoJSON
- ‘MultiPolygon’ format, a list of ee.Geometry describing a Polygon, or a list of number defining a single polygon boundary.
- proj: The projection of this geometry. If unspecified, the default is the
- projection of the input ee.Geometry, or EPSG:4326 if there are no ee.Geometry inputs.
- geodesic: If false, edges are straight in the projection. If true, edges
- are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers.
- maxError: Max error when input geometry must be reprojected to an
- explicitly requested result projection or geodesic state.
- evenOdd: If true, polygon interiors will be determined by the even/odd
- rule, where a point is inside if it crosses an odd number of edges to reach a point at infinity. Otherwise polygons use the left-inside rule, where interiors are on the left side of the shell’s edges when walking the vertices in the given order. If unspecified, defaults to True.
- *args: For convenience, varargs may be used when all arguments are
- numbers. This allows creating geodesic EPSG:4326 MultiPolygons with a single Polygon with a single LinearRing given an even number of arguments, e.g. ee.Geometry.MultiPolygon(aLng, aLat, bLng, bLat, …, aLng, aLat).
- Returns:
- An ee.Geometry describing a MultiPolygon.
-
static
Point
(coords=<object object>, proj=<object object>, *args, **kwargs)¶ Constructs an ee.Geometry describing a point.
- Args:
coords: A list of two [x,y] coordinates in the given projection. proj: The projection of this geometry, or EPSG:4326 if unspecified. *args: For convenience, varargs may be used when all arguments are
numbers. This allows creating EPSG:4326 points, e.g. ee.Geometry.Point(lng, lat).- **kwargs: Keyword args that accept “lon” and “lat” for backward-
- compatibility.
- Returns:
- An ee.Geometry describing a point.
-
static
Polygon
(coords=<object object>, proj=<object object>, geodesic=<object object>, maxError=<object object>, evenOdd=<object object>, *args)¶ Constructs an ee.Geometry describing a polygon.
- Args:
- coords: A list of rings defining the boundaries of the polygon. May be a
- list of coordinates in the GeoJSON ‘Polygon’ format, a list of ee.Geometry describing a LinearRing, or a list of number defining a single polygon boundary.
- proj: The projection of this geometry. If unspecified, the default is the
- projection of the input ee.Geometry, or EPSG:4326 if there are no ee.Geometry inputs.
- geodesic: If false, edges are straight in the projection. If true, edges
- are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers.
- maxError: Max error when input geometry must be reprojected to an
- explicitly requested result projection or geodesic state.
- evenOdd: If true, polygon interiors will be determined by the even/odd
- rule, where a point is inside if it crosses an odd number of edges to reach a point at infinity. Otherwise polygons use the left-inside rule, where interiors are on the left side of the shell’s edges when walking the vertices in the given order. If unspecified, defaults to True.
- *args: For convenience, varargs may be used when all arguments are
- numbers. This allows creating geodesic EPSG:4326 Polygons with a single LinearRing given an even number of arguments, e.g. ee.Geometry.Polygon(aLng, aLat, bLng, bLat, …, aLng, aLat).
- Returns:
- An ee.Geometry describing a polygon.
-
static
Rectangle
(coords=<object object>, proj=<object object>, geodesic=<object object>, evenOdd=<object object>, *args, **kwargs)¶ Constructs an ee.Geometry describing a rectangular polygon.
- Args:
- coords: The minimum and maximum corners of the rectangle, as a list of
- two points each in the format of GeoJSON ‘Point’ coordinates, or a list of two ee.Geometry describing a point, or a list of four numbers in the order xMin, yMin, xMax, yMax.
- proj: The projection of this geometry. If unspecified, the default is the
- projection of the input ee.Geometry, or EPSG:4326 if there are no ee.Geometry inputs.
- geodesic: If false, edges are straight in the projection. If true, edges
- are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers.
- evenOdd: If true, polygon interiors will be determined by the even/odd
- rule, where a point is inside if it crosses an odd number of edges to reach a point at infinity. Otherwise polygons use the left-inside rule, where interiors are on the left side of the shell’s edges when walking the vertices in the given order. If unspecified, defaults to True.
- *args: For convenience, varargs may be used when all arguments are
- numbers. This allows creating EPSG:4326 Polygons given exactly four coordinates, e.g. ee.Geometry.Rectangle(minLng, minLat, maxLng, maxLat).
- **kwargs: Keyword args that accept “xlo”, “ylo”, “xhi” and “yhi” for
- backward-compatibility.
- Returns:
- An ee.Geometry describing a rectangular polygon.
-
encode
(opt_encoder=None)¶ Returns a GeoJSON-compatible representation of the geometry.
-
encode_cloud_value
(encoder)¶ Returns a server-side invocation of the appropriate constructor.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
serialize
()¶ Returns the serialized representation of this object.
-
toGeoJSON
()¶ Returns a GeoJSON representation of the geometry.
-
toGeoJSONString
()¶ Returns a GeoJSON string representation of the geometry.
-
static
ee.image module¶
A representation of an Earth Engine image.
See: https://sites.google.com/site/earthengineapidocs for more details.
-
class
ee.image.
Image
(args=None, version=None)¶ Bases:
ee.element.Element
An object to represent an Earth Engine image.
-
static
cat
(*args)¶ Concatenate the given images together into a single image.
-
clip
(clip_geometry)¶ Clips an image to a Geometry or Feature.
The output bands correspond exactly the input bands, except data not covered by the geometry is masked. The output image retains the metadata of the input image.
Use clipToCollection to clip an image to a FeatureCollection.
- Args:
- clip_geometry: The Geometry or Feature to clip to.
- Returns:
- The clipped image.
-
static
combine_
(images, names=None)¶ Combine all the bands from the given images into a single image.
- Args:
- images: The images to be combined. names: An array of names for the output bands.
- Returns:
- The combined image.
-
expression
(expression, opt_map=None)¶ Evaluates an arithmetic expression on an image or images.
The bands of the primary input image are available using the built-in function b(), as b(0) or b(‘band_name’).
Variables in the expression are interpreted as additional image parameters which must be supplied in opt_map. The bands of each such image can be accessed like image.band_name or image[0].
Both b() and image[] allow multiple arguments, to specify multiple bands, such as b(1, ‘name’, 3). Calling b() with no arguments, or using a variable by itself, returns all bands of the image.
- Args:
- expression: The expression to evaluate. opt_map: An optional map of input images available by name.
- Returns:
- The image computed by the provided expression.
-
getDownloadURL
(params=None)¶ Get a download URL for this image.
- Args:
- params: An object containing visualization options with the following
- possible values:
name - a base name to use when constructing filenames. bands - a description of the bands to download. Must be an array of
dictionaries, each with the following keys:id - the name of the band, a string, required. crs - an optional CRS string defining the band projection. crs_transform - an optional array of 6 numbers specifying an affine
transform from the specified CRS, in the order: xScale, yShearing, xShearing, yScale, xTranslation and yTranslation.- dimensions - an optional array of two integers defining the width and
- height to which the band is cropped.
- scale - an optional number, specifying the scale in meters of the
- band; ignored if crs and crs_transform is specified.
- crs - a default CRS string to use for any bands that do not explicitly
- specify one.
- crs_transform - a default affine transform to use for any bands that do
- not specify one, of the same format as the crs_transform of bands.
- dimensions - default image cropping dimensions to use for any bands
- that do not specify them.
- scale - a default scale to use for any bands that do not specify one;
- ignored if crs and crs_transform is specified.
- region - a polygon specifying a region to download; ignored if crs
- and crs_transform is specified.
- Returns:
- A URL to download the specified image.
-
getDownloadUrl
(params=None)¶ Get a download URL for this image.
- Args:
- params: An object containing visualization options with the following
- possible values:
name - a base name to use when constructing filenames. bands - a description of the bands to download. Must be an array of
dictionaries, each with the following keys:id - the name of the band, a string, required. crs - an optional CRS string defining the band projection. crs_transform - an optional array of 6 numbers specifying an affine
transform from the specified CRS, in the order: xScale, yShearing, xShearing, yScale, xTranslation and yTranslation.- dimensions - an optional array of two integers defining the width and
- height to which the band is cropped.
- scale - an optional number, specifying the scale in meters of the
- band; ignored if crs and crs_transform is specified.
- crs - a default CRS string to use for any bands that do not explicitly
- specify one.
- crs_transform - a default affine transform to use for any bands that do
- not specify one, of the same format as the crs_transform of bands.
- dimensions - default image cropping dimensions to use for any bands
- that do not specify them.
- scale - a default scale to use for any bands that do not specify one;
- ignored if crs and crs_transform is specified.
- region - a polygon specifying a region to download; ignored if crs
- and crs_transform is specified.
- Returns:
- A URL to download the specified image.
DEPRECATED: Use getDownloadURL().
-
getInfo
()¶ Fetch and return information about this image.
- Returns:
- The return contents vary but will include at least:
- bands - Array containing metadata about the bands in the image, properties - Dictionary containing the image’s metadata properties.
-
getMapId
(vis_params=None)¶ Fetch and return a map id and token, suitable for use in a Map overlay.
- Args:
- vis_params: The visualization parameters. See ee.data.getMapId.
- Returns:
- An object containing a mapid and access token, or an error message.
-
getThumbId
(params)¶ Applies transformations and returns the thumbId.
- Args:
- params: Parameters identical to getMapId, plus, optionally:
- dimensions - (a number or pair of numbers in format WIDTHxHEIGHT) Max
- dimensions of the thumbnail to render, in pixels. If only one number is passed, it is used as the maximum, and the other dimension is computed by proportional scaling.
- region - (E,S,W,N or GeoJSON) Geospatial region of the image
- to render. By default, the whole image.
format - (string) Either ‘png’ or ‘jpg’.
- Returns:
- A thumbId for the created thumbnail.
- Raises:
- EEException: If the region parameter is not an array or GeoJSON object.
-
getThumbURL
(params=None)¶ Get a thumbnail URL for this image.
- Args:
- params: Parameters identical to getMapId, plus, optionally:
- dimensions - (a number or pair of numbers in format WIDTHxHEIGHT) Max
- dimensions of the thumbnail to render, in pixels. If only one number is passed, it is used as the maximum, and the other dimension is computed by proportional scaling.
- region - (E,S,W,N or GeoJSON) Geospatial region of the image
- to render. By default, the whole image.
format - (string) Either ‘png’ or ‘jpg’.
- Returns:
- A URL to download a thumbnail the specified image.
- Raises:
- EEException: If the region parameter is not an array or GeoJSON object.
-
getThumbUrl
(params=None)¶ Get a thumbnail URL for this image.
- Args:
- params: Parameters identical to getMapId, plus, optionally:
- dimensions - (a number or pair of numbers in format WIDTHxHEIGHT) Max
- dimensions of the thumbnail to render, in pixels. If only one number is passed, it is used as the maximum, and the other dimension is computed by proportional scaling.
- region - (E,S,W,N or GeoJSON) Geospatial region of the image
- to render. By default, the whole image.
format - (string) Either ‘png’ or ‘jpg’.
- Returns:
- A URL to download a thumbnail the specified image.
- Raises:
- EEException: If the region parameter is not an array or GeoJSON object.
DEPRECATED: Use getThumbURL().
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
prepare_for_export
(params)¶ Applies all relevant export parameters to an image.
- Args:
- params: the export request parameters.
- Returns:
A tuple containing: - an image that has had many of the request parameters applied
to it- any remaining parameters.
-
rename
(names, *args)¶ Rename the bands of an image.
Can be called with either a list of strings or any number of strings.
- Args:
- names: An array of strings specifying the new names for the
- bands. Must exactly match the number of bands in the image.
*args: Band names as varargs.
- Returns:
- An image with the renamed bands.
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
static
rgb
(r, g, b)¶ Create a 3-band image.
This creates a 3-band image specifically for visualization using the first band in each image.
- Args:
- r: The red image. g: The green image. b: The blue image.
- Returns:
- The combined image.
-
select
(opt_selectors=None, opt_names=None, *args)¶ Selects bands from an image.
- Can be called in one of two ways:
- Passed any number of non-list arguments. All of these will be interpreted as band selectors. These can be band names, regexes, or numeric indices. E.g. selected = image.select(‘a’, ‘b’, 3, ‘d’);
- Passed two lists. The first will be used as band selectors and the second as new names for the selected bands. The number of new names must match the number of selected bands. E.g. selected = image.select([‘a’, 4], [‘newA’, ‘newB’]);
- Args:
- opt_selectors: An array of names, regexes or numeric indices specifying
- the bands to select.
- opt_names: An array of strings specifying the new names for the
- selected bands.
*args: Selector elements as varargs.
- Returns:
- An image with the selected bands.
-
static
ee.imagecollection module¶
Representation for an Earth Engine ImageCollection.
-
class
ee.imagecollection.
ImageCollection
(args)¶ Bases:
ee.collection.Collection
Representation for an Earth Engine ImageCollection.
-
static
elementType
()¶ Returns the type of the collection’s elements.
-
first
()¶ Returns the first entry from a given collection.
- Returns:
- The first entry from the collection.
-
getFilmstripThumbURL
(params=None)¶ Get the URL for a “filmstrip” thumbnail of the given collection.
- Args:
params: Parameters identical to getMapId, plus, optionally: dimensions -
(a number or pair of numbers in format WIDTHxHEIGHT) Max dimensions of the thumbnail to render, in pixels. If only one number is passed, it is used as the maximum, and the other dimension is computed by proportional scaling.crs - a CRS string specifying the projection of the output. crs_transform - the affine transform to use for the output pixel grid. scale - a scale to determine the output pixel grid; ignored if both crs
and crs_transform are specified.- region - (E,S,W,N or GeoJSON) Geospatial region of the result. By default,
- the whole image.
format - (string) The output format (e.g., “png”, “jpg”).
- Returns:
- A URL to download a thumbnail of the specified ImageCollection.
- Raises:
- EEException: If the region parameter is not an array or GeoJSON object.
-
getMapId
(vis_params=None)¶ Fetch and return a MapID.
This mosaics the collection to a single image and return a mapid suitable for building a Google Maps overlay.
- Args:
- vis_params: The visualization parameters.
- Returns:
- A mapid and token.
-
classmethod
initialize
()¶ Imports API functions to this class.
-
static
name
()¶ Returns the name of the object, used in __str__().
-
prepare_for_export
(params)¶ Applies all relevant export parameters to an ImageCollection.
- Args:
- params: The export request parameters.
- Returns:
A tuple containing: - an ImageCollection that has had many of the request parameters applied
to it- any remaining parameters.
-
classmethod
reset
()¶ Removes imported API functions from this class.
-
select
(selectors, opt_names=None, *args)¶ Select bands from each image in a collection.
- Args:
- selectors: An array of names, regexes or numeric indices specifying
- the bands to select.
- opt_names: An array of strings specifying the new names for the
- selected bands. If supplied, the length must match the number of bands selected.
*args: Selector elements as varargs.
- Returns:
- The image collection with selected bands.
-
static
ee.mapclient module¶
A slippy map GUI.
Implements a tiled slippy map using Tk canvas. Displays map tiles using whatever projection the tiles are in and only knows about tile coordinates, (as opposed to geospatial coordinates.) This assumes that the tile-space is organized as a power-of-two pyramid, with the origin in the upper left corner. This currently has several spots that are hard-coded for 256x256 tiles, even though MapOverlay tries to track this.
Supports mouse-based pan and zoom as well as tile upsampling while waiting for new tiles to load. The map to display is specified by a MapOverlay, and added to the GUI on creation or manually using addOverlay()
gui = MapClient(MakeOverlay(mapid))
Tiles are referenced using a key of (level, x, y) throughout.
Several of the functions are named to match the Google Maps Javascript API, and therefore violate style guidelines.
-
ee.mapclient.
MakeOverlay
(mapid, baseurl='https://earthengine.googleapis.com')¶ Create an overlay from a mapid.
-
class
ee.mapclient.
MapClient
(opt_overlay=None, opt_width=1024, opt_height=768)¶ Bases:
threading.Thread
A simple discrete zoom level map viewer.
-
AddTile
(image, key, overlay, layer)¶ Add a tile to the map.
This keeps track of the tiles for each overlay in each grid cell. As new tiles come in, all the tiles in a grid cell are composited together into a new tile and any old tile for that spot is replaced.
- Args:
image: The image tile to display. key: A tuple containing the key of the image (level, x, y) overlay: The overlay this tile belongs to. layer: The layer number this overlay corresponds to. Only used
for caching purposes.
-
CenterMap
(lon, lat, opt_zoom=None)¶ Center the map at the given lon, lat and zoom level.
-
ClickHandler
(event)¶ Records the anchor location and sets drag handler.
-
CompositeTiles
(key)¶ Composite together all the tiles in this cell into a single image.
-
DragHandler
(event)¶ Updates the map position and anchor position.
-
Flush
()¶ Empty out all the image fetching queues.
-
GetFrameSize
()¶
-
GetMapSize
()¶
-
GetViewport
()¶ Return the visible portion of the map as [xlo, ylo, xhi, yhi].
-
KeypressHandler
(event)¶ Handle keypress events.
-
LoadTiles
()¶ Refresh the entire map.
-
ReleaseHandler
(unused_event)¶ Unbind drag handler and redraw.
-
ResizeHandler
(event)¶ Handle resize events.
-
Zoom
(event, direction)¶ Zoom the map.
- Args:
- event: The event that caused this zoom request. direction: The direction to zoom. +1 for higher zoom, -1 for lower.
-
addOverlay
(overlay)¶ Add an overlay to the map.
-
run
()¶ Set up the user interface.
-
-
class
ee.mapclient.
MapOverlay
(url, tile_fetcher=None)¶ Bases:
object
A class representing a map overlay.
-
CalcTiles
(level, bbox)¶ Calculate which tiles to load based on the visible viewport.
- Args:
- level: The level at which to calculate the required tiles. bbox: The viewport coordinates as a tuple (xlo, ylo, xhi, yhi])
- Returns:
- The list of tile keys to fill the given viewport.
-
Flush
()¶ Empty the tile queue.
-
GetCachedTile
(key)¶ Returns the specified tile if it’s in the cache.
-
Interpolate
(key, callback)¶ Upsample a lower res tile if one is available.
- Args:
- key: The tile key to upsample. callback: The callback to call when the tile is ready.
-
MAX_CACHE
= 1000¶
-
PutCacheTile
(key, image)¶ Insert a new tile in the cache and eject old ones if it’s too big.
-
TILE_HEIGHT
= 256¶
-
TILE_WIDTH
= 256¶
-
class
TileFetcher
(overlay)¶ Bases:
threading.Thread
A threaded URL fetcher.
-
run
()¶ Pull URLs off the ovelay’s queue and call the callback when done.
-
-
getTile
(key, callback)¶ Get the requested tile.
If the requested tile is already cached, it’s returned (sent to the callback) directly. If it’s not cached, a check is made to see if a lower-res version is cached, and if so that’s interpolated up, before a request for the actual tile is made.
- Args:
key: The key of the tile to fetch. callback: The callback to call when the tile is available. The callback
may be called more than once if a low-res version is available.
-
-
ee.mapclient.
addToMap
(eeobject, vis_params=None, *unused_args)¶ Adds a layer to the default map instance.
- Args:
eeobject: the object to add to the map. vis_params: a dictionary of visualization parameters. See
ee.data.getMapId().*unused_args: unused arguments, left for compatibility with the JS API.
This call exists to be an equivalent to the playground addToMap() call. It uses a global MapInstance to hang on to “the map”. If the MapInstance isn’t initialized, this creates a new one.
-
ee.mapclient.
centerMap
(lng, lat, zoom)¶ Center the default map instance at the given lat, lon and zoom values.
ee.oauth module¶
Earth Engine OAuth2 helper functions for generating client tokens.
Typical use-case consists of: 1. Calling ‘get_authorization_url’ 2. Using a browser to access the output URL and copy the generated OAuth2 code 3. Calling ‘request_token’ to request a token using that code and the OAuth API 4. Calling ‘write_token’ to save the token at the path given by
‘get_credentials_path’
Returns a URL to generate an auth code.
-
ee.oauth.
get_credentials_path
()¶
-
ee.oauth.
request_token
(auth_code)¶ Uses authorization code to request tokens.
-
ee.oauth.
write_token
(refresh_token)¶ Attempts to write the passed token to the given user directory.
ee.serializer module¶
A serializer that encodes EE object trees as JSON DAGs.
-
ee.serializer.
DatetimeToMicroseconds
(date)¶ Convert a datetime to a timestamp, microseconds since the epoch.
-
class
ee.serializer.
Serializer
(is_compound=True, for_cloud_api=False)¶ Bases:
object
A serializer for EE object trees.
-
ee.serializer.
encode
(obj, is_compound=True, for_cloud_api=False)¶ Serialize an object to a JSON-compatible structure for API calls.
- Args:
obj: The object to serialize. is_compound: Whether the encoding should factor out shared subtrees. for_cloud_api: Whether the encoding should be done for the Cloud API
or the legacy API.- Returns:
- A JSON-compatible structure representing the input.
-
ee.serializer.
toJSON
(obj, opt_pretty=False, for_cloud_api=False)¶ Serialize an object to a JSON string appropriate for API calls.
- Args:
obj: The object to serialize. opt_pretty: True to pretty-print the object. for_cloud_api: Whether the encoding should be done for the Cloud API
or the legacy API.- Returns:
- A JSON string representing the input.
-
ee.serializer.
toReadableJSON
(obj)¶ Convert an object to readable JSON.
ee.terrain module¶
A namespace for Terrain.
Module contents¶
The EE Python library.
-
ee.
Initialize
(credentials='persistent', opt_url=None, use_cloud_api=False, cloud_api_key=None, http_transport=None, project=None)¶ Initialize the EE library.
If this hasn’t been called by the time any object constructor is used, it will be called then. If this is called a second time with a different URL, this doesn’t do an un-initialization of e.g.: the previously loaded Algorithms, but will overwrite them and let point at alternate servers.
- Args:
- credentials: OAuth2 credentials. ‘persistent’ (default) means use
- credentials already stored in the filesystem, or raise an explanatory exception guiding the user to create those credentials.
opt_url: The base url for the EarthEngine REST API to connect to. use_cloud_api: Whether the Cloud API should be used. cloud_api_key: An optional API key to use the Cloud API. http_transport: The http transport method to use when making requests. project: The project-id or number to use when making api calls.
-
ee.
Reset
()¶ Reset the library. Useful for re-initializing to a different server.