J.J
J.J

Reputation: 51

possible to upload shapefiles in google earth engine python api?

Is it possible to upload shapefiles or geoJSON as assets with the Google Earth Engine python API?

While it's super easy with the upload tap of the JavaScript API in the Browser, I could not find any solution for the python API.

Upvotes: 4

Views: 3899

Answers (4)

dvegamar
dvegamar

Reputation: 11

Following Quisheng Wu:

first I created a region of interest with polygons and landsat data and exported it in shp files.

geemap.ee_to_shp(ROI,filename = 'ROI_completo.shp',  keep_zip=True)

it is stored in colab drive. Then I can recover it with:

ROI_shp = '/content/drive/MyDrive/ content sample_data/ROI_completo.shp'
ROI = geemap.shp_to_ee(ROI_shp)

but obviously you can upload any shp files you need.

While working in colab notebooks It showed a warning. You need to have geopandas instaled for the shp_to_ee to work.

If so, then

!pip install pyshp
!pip install geopandas

Upvotes: 0

intotecho
intotecho

Reputation: 5684

No, as at 2021, it is not possible to upload shapefiles or GeoJson via the API. There is no equivalent of ee.Image.loadGeoTIFF(uri) that loads an image from a public uri.

It used to be possible to load a Feature Collection from Google Fusion Tables, but fusion tables, an experimental product, was closed in 2019. BigQuery might be the successor to Fusion Tables, but the Earth Engine API doesn't connect to BigQuery - yet.

There was a Next21 announcement that 'Google Cloud customers will be able to integrate Earth Engine with BigQuery'.

There are some limited options to consider:

The Earth Engine command line upload function will upload shape files, and GeoJson. This is a CLI, not an API but your app could shell out to it if it is installed and the authentication is setup. If you are running on AppEngine standard, that won't be available.

If the table data is GeoJSON, and less than 500K, you could paste it into an ee.FeatureCollection(buffer). If larger, you would need to split it up. This would be a slow operation.

If the table can be converted (e.g. interpolation, kriging, clustering) into a GeoTIFF image then you have the loadGeoTIFF option.

Upvotes: 0

Richard
Richard

Reputation: 3

This is possible with the geemap package from Dr. Quisheng Wu from University of Tennessee Knoxville.

There's an example notebook for the geemap.shp_to_ee() function here: https://github.com/giswqs/geemap/blob/master/examples/notebooks/10_shapefiles.ipynb

Upvotes: 0

Nicholas Clinton
Nicholas Clinton

Reputation: 893

You may want to investigate the Earth Engine command line upload function.

Upvotes: 1

Related Questions