google-earth-engine – How to Import Shapefile in GEE Python API

google-earth-enginegoogle-earth-engine-python-api

I know how to use GEE with JavaScript to import the shapefile, which is just uploading file to asset, then import it in JavaScript code, just like this:

var counties: Table user/wxystudio/cb_2016_us_county

It will be automatically transferred to a FeatureCollection object in GEE.

But how can I import this file as FeatureCollection in Python?

Best Answer

You can install the Earth Engine Python API using pip install earthengine-api

Once you install ee module, open your Jupyter Notebook and run these followinge codes to import the feature collection

import ee

# Trigger the authentication flow.
ee.Authenticate()

# Initialize the library.
ee.Initialize()

feature_collection = ee.FeatureCollection('user/wxystudio/cb_2016_us_county')

If you don't want to install earth engine python api on your local machine, you can always try coding on Google Colab. The ee module is installed by default there.

Related Question