# Exporting Table and Vector Data

You can export a `FeatureCollection` as CSV, SHP (shapefile), GeoJSON, KML, KMZ
or TFRecord using `Export.table`. The `FeatureCollection` may represent vectors
or simply a table of data. In the latter case, the features in the collection
will have null geometry.

Note some additional constraints when working with some file formats, including:

- **KML** : A `FeatureCollection` exported to a KML file will have all the geometries transformed to unprojected (WGS84) coordinates.
- **SHP** : A `FeatureCollection` exported to a Shapefile must contain features with the same geometry type and projection and must fit within the [Shapefile size
  limits](https://support.esri.com/en/technical-article/000010813). Column names are truncated to 10 characters or fewer, and this must not create duplicate column names.
- **TFRecord** : See [this page](https://developers.google.com/earth-engine/guides/tfrecord#exporting-tables).

> [!NOTE]
> **Note:** If you need control over the precision of geometries in your export, `map()` a function over the collection to be exported: `map(function(f) { return f.transform(targetProj, maxErr); })`

## to Cloud Storage

To export a `FeatureCollection` to Cloud Storage, use
`Export.table.toCloudStorage()`. For example, using the `features` defined
previously:

### Code Editor (JavaScript)

```javascript
// Make a collection of points.
var features = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point(30.41, 59.933), {name: 'Voronoi'}),
  ee.Feature(ee.Geometry.Point(-73.96, 40.781), {name: 'Thiessen'}),
  ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {name: 'Dirichlet'})
]);

// Export a KML file to Cloud Storage.
Export.table.toCloudStorage({
  collection: features,
  description:'vectorsToCloudStorageExample',
  bucket: 'your-bucket-name',
  fileNamePrefix: 'exampleTableExport',
  fileFormat: 'KML'
});
```
Python setup

See the [Python Environment](https://developers.google.com/earth-engine/guides/python_install) page for information on the Python API and using
`geemap` for interactive development.

```python
import ee
import geemap.core as geemap
```

### Colab (Python)

```python
# Make a collection of points.
features = ee.FeatureCollection([
    ee.Feature(ee.Geometry.Point(30.41, 59.933), {'name': 'Voronoi'}),
    ee.Feature(ee.Geometry.Point(-73.96, 40.781), {'name': 'Thiessen'}),
    ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {'name': 'Dirichlet'}),
])

# Export a KML file to Cloud Storage.
task = ee.batch.Export.table.toCloudStorage(
    collection=features,
    description='vectorsToCloudStorageExample',
    bucket='your-bucket-name',
    fileNamePrefix='exampleTableExport',
    fileFormat='KML',
)
task.start()
```

## to Asset

To export a `FeatureCollection` as an Earth Engine asset, use
`Export.table.toAsset()`. For example, using the `features` defined previously:

### Code Editor (JavaScript)

```javascript
// Export an ee.FeatureCollection as an Earth Engine asset.
Export.table.toAsset({
  collection: features,
  description:'exportToTableAssetExample',
  assetId: 'exampleAssetId',
});
```
Python setup

See the [Python Environment](https://developers.google.com/earth-engine/guides/python_install) page for information on the Python API and using
`geemap` for interactive development.

```python
import ee
import geemap.core as geemap
```

### Colab (Python)

```python
# Export an ee.FeatureCollection as an Earth Engine asset.
task = ee.batch.Export.table.toAsset(
    collection=features,
    description='exportToTableAssetExample',
    assetId='projects/your-project/assets/exampleAssetId',
)
task.start()
```

There are several limitations on the size and shape of Earth Engine table
assets:

- Maximum of 100 million features
- Maximum of 1,000 properties (columns)
- Maximum of 100,000 vertices for each row's geometry
- Maximum of 100,000 characters per string value

## to BigQuery

You can export a `FeatureCollection` to a BigQuery table using
[`Export.table.toBigQuery()`](https://developers.google.com/earth-engine/apidocs/export-table-tobigquery).
This lets you integrate your Earth Engine data with other data and tools
available in BigQuery. For more information, see the
[Exporting to BigQuery guide](https://developers.google.com/earth-engine/guides/exporting_to_bigquery).

### Code Editor (JavaScript)

```javascript
Export.table.toBigQuery({
  collection: features,
  table: 'myproject.mydataset.mytable',
  description: 'put_my_data_in_bigquery',
  append: true,
  overwrite: false
});
```
Python setup

See the [Python Environment](https://developers.google.com/earth-engine/guides/python_install) page for information on the Python API and using
`geemap` for interactive development.

```python
import ee
import geemap.core as geemap
```

### Colab (Python)

```python
task = ee.batch.Export.table.toBigQuery(
    collection=features,
    table='myproject.mydataset.mytable',
    description='put_my_data_in_bigquery',
    append=True,
    overwrite=False,
)
task.start()
```

## to Drive

To export a `FeatureCollection` to your Drive account, use
`Export.table.toDrive()`. For example:

### Code Editor (JavaScript)

```javascript
// Export the FeatureCollection to a KML file.
Export.table.toDrive({
  collection: features,
  description:'vectorsToDriveExample',
  fileFormat: 'KML'
});
```
Python setup

See the [Python Environment](https://developers.google.com/earth-engine/guides/python_install) page for information on the Python API and using
`geemap` for interactive development.

```python
import ee
import geemap.core as geemap
```

### Colab (Python)

```python
# Export the FeatureCollection to a KML file.
task = ee.batch.Export.table.toDrive(
    collection=features, description='vectorsToDriveExample', fileFormat='KML'
)
task.start()
```

Note that the output format is specified as KML to handle geographic data (SHP
would also be appropriate for exporting a table with geometry). To export just a
table of data, without any geographic information, export features with null
geometry in CSV format. The following demonstrates using
`Export.table.toDrive()` to get the results of a potentially long running
reduction:

### Code Editor (JavaScript)

```javascript
// Load a Landsat image.
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318');
var projection = image.select('B2').projection().getInfo();

// Create an arbitrary rectangle.
var region = ee.Geometry.Rectangle(-122.2806, 37.1209, -122.0554, 37.2413);

// Get a dictionary of means in the region.
var means = image.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: region,
  crs: projection.crs,
  crsTransform: projection.transform,
});

// Make a feature without geometry and set the properties to the dictionary of means.
var feature = ee.Feature(null, means);

// Wrap the Feature in a FeatureCollection for export.
var featureCollection = ee.FeatureCollection([feature]);

// Export the FeatureCollection.
Export.table.toDrive({
  collection: featureCollection,
  description: 'exportTableExample',
  fileFormat: 'CSV'
});
```
Python setup

See the [Python Environment](https://developers.google.com/earth-engine/guides/python_install) page for information on the Python API and using
`geemap` for interactive development.

```python
import ee
import geemap.core as geemap
```

### Colab (Python)

```python
# Load a Landsat image.
image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')
projection = image.select('B2').projection().getInfo()

# Create an arbitrary rectangle.
region = ee.Geometry.Rectangle(-122.2806, 37.1209, -122.0554, 37.2413)

# Get a dictionary of means in the region.
means = image.reduceRegion(
    reducer=ee.Reducer.mean(),
    geometry=region,
    crs=projection['crs'],
    crsTransform=projection['transform'],
)

# Make a feature without geometry and set the properties to the dictionary of means.
feature = ee.Feature(None, means)

# Wrap the Feature in a FeatureCollection for export.
feature_collection = ee.FeatureCollection([feature])

# Export the FeatureCollection.
task = ee.batch.Export.table.toDrive(
    collection=feature_collection,
    description='exportTableExample',
    fileFormat='CSV',
)
task.start()
```

Note that the format is set to 'CSV' in this example since there is no geometry
in the output.

> [!CAUTION]
> **Caution:** Depending on your Google Drive settings, CSV tables that you export from Earth Engine can be converted to XSLX files with unintended effects, such as data type conversions. The behavior can be modified with [Google Drive
> settings](https://developers.google.com/earth-engine/faq#tables_exported_to_drive_as_csv_format_are_converted_to_xslx_format).