geetools.batch.featurecollection#

TODO missing docstring.

Module Contents#

Functions#

fromGeoJSON([filename, data, crs])

Create a list of Features from a GeoJSON file. Return a python tuple.

fromKML([filename, data, crs, encoding])

Create a list of Features from a KML file. Return a python tuple.

fromShapefile(filename[, crs, start, end])

Convert an ESRI file (.shp and .dbf must be present) to a.

toAsset(table, assetPath[, name, create, verbose])

This function can create folders and ImageCollections on the fly.

toCSV(collection, filename[, split_at])

Alternative to download a FeatureCollection as a CSV.

toDict(collection[, split_at])

Get the FeatureCollection as a dict object.

toDriveShapefile(collection[, description, folder, ...])

Export a FeatureCollection to a SHP in Google Drive. The advantage of.

toGeoJSON(collection, name[, path, split_at])

Export a FeatureCollection to a GeoJSON file.

toLocal(collection, filename[, filetype, selectors, path])

Download a FeatureCollection to a local file a CSV or geoJSON file.

geetools.batch.featurecollection.fromGeoJSON(filename=None, data=None, crs=None)[source]#

Create a list of Features from a GeoJSON file. Return a python tuple.

with ee.Feature inside. This is due to failing when attempting to create a FeatureCollection (Broken Pipe ERROR) out of the list. You can try creating it yourself casting the result of this function to a ee.List or using it directly as a FeatureCollection argument.

Parameters:
  • filename (str) – the name of the file to load

  • crs – a coordinate reference system in EPSG format. If not specified it will try to get it from the geoJSON, and if not there it will rise an error

Type:

crs: str

Returns:

a tuple of features.

geetools.batch.featurecollection.fromKML(filename=None, data=None, crs=None, encoding=None)[source]#

Create a list of Features from a KML file. Return a python tuple.

with ee.Feature inside. This is due to failing when attempting to create a FeatureCollection (Broken Pipe ERROR) out of the list. You can try creating it yourself casting the result of this function to a ee.List or using it directly as a FeatureCollection argument.

Parameters:
  • filename (str) – the name of the file to load

  • crs – a coordinate reference system in EPSG format. If not specified it will try to get it from the geoJSON, and if not there it will rise an error

Type:

crs: str

Returns:

a tuple of features.

geetools.batch.featurecollection.fromShapefile(filename, crs=None, start=None, end=None)[source]#

Convert an ESRI file (.shp and .dbf must be present) to a.

ee.FeatureCollection.

At the moment only works for shapes with less than 1000 records and doesn’t handle complex shapes.

Parameters:
  • filename (str) – the name of the filename. If the shape is not in the same path than the script, specify a path instead.

  • start

Returns:

the FeatureCollection

Return type:

ee.FeatureCollection

geetools.batch.featurecollection.toAsset(table, assetPath, name=None, create=True, verbose=False, **kwargs)[source]#

This function can create folders and ImageCollections on the fly.

The rest is the same to Export.image.toAsset. You can pass the same params as the original function.

Parameters:
  • table (ee.FeatureCollection) – the feature collection to upload

  • assetPath (str) – path to upload the image (only PATH, without filename)

  • name (str) – filename for the image (AssetID will be assetPath + name)

Returns:

the tasks

Return type:

ee.batch.Task

geetools.batch.featurecollection.toCSV(collection, filename, split_at=4000)[source]#

Alternative to download a FeatureCollection as a CSV.

geetools.batch.featurecollection.toDict(collection, split_at=4000)[source]#

Get the FeatureCollection as a dict object.

geetools.batch.featurecollection.toDriveShapefile(collection, description='myExportTableTask', folder=None, fileNamePrefix=None, selectors=None, types=None, verbose=True, **kwargs)[source]#

Export a FeatureCollection to a SHP in Google Drive. The advantage of.

this over the one provided by GEE is that this function takes care of the geometries and exports one shapefile per geometry, so at the end you could get many shapefiles .

geetools.batch.featurecollection.toGeoJSON(collection, name, path=None, split_at=4000)[source]#

Export a FeatureCollection to a GeoJSON file.

Parameters:
  • collection (ee.FeatureCollection) – The collection to export

  • name (str) – name of the resulting file

  • path (str) – The path where to save the file. If None, will be saved in the current folder

  • split_at (int) – limit to avoid an EE Exception

Returns:

A GeoJSON (.geojson) file.

Return type:

file

geetools.batch.featurecollection.toLocal(collection, filename, filetype=None, selectors=None, path=None)[source]#

Download a FeatureCollection to a local file a CSV or geoJSON file.

This uses a different method than toGeoJSON and toCSV.

Parameters:
  • 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