简体   繁体   English

将地球引擎特征集合转换为 python 中的 dataframe

[英]Convert earth engine feature collection to a dataframe in python

I uploaded a shapefile in my earth engine account as a feature collection and I now I need to use it in a jupyter lab notebook.我在我的地球引擎帐户中上传了一个 shapefile 作为功能集合,现在我需要在 jupyter 实验室笔记本中使用它。

I use the following code to import the collection:我使用以下代码导入集合:

df = ee.FeatureCollection('users/my_user/my_shape')

But now I don't know how to convert to into a dataframe.但现在我不知道如何转换为 dataframe。 Any ideas?有任何想法吗?

You should be able to do this using geemap .您应该能够使用geemap做到这一点。

gdf = geemap.ee_to_pandas(df)

Feature collection to pandas dataframe: pandas dataframe 的功能集合:

nested_list = results.reduceColumns(ee.Reducer.toList(len(column_df)), column_df).values().get(0)
data = nested_list.getInfo()
data

# dont forget we need to call the callback method "getInfo" to retrieve the data
df = pd.DataFrame(data, columns=column_df)
# we obtain the data frame as per our demand
df

You can visit the blog post: https://kaflekrishna.com.np/blog-detail/extraction-raster-values-point-samples-google-earth-engine-gee/您可以访问博客文章: https://kaflekrishna.com.np/blog-detail/extraction-raster-values-point-samples-google-earth-engine-gee/

Find: "Method 1: Feature collection to pandas dataframe" on step 11, then you can convert feature collection to pandas dataframe, you will find the whole case scenario in which I faced & used this example as well.在步骤 11 中找到:“方法 1:特征集合到 pandas 数据帧”,然后您可以将特征集合转换为 pandas dataframe,您会发现在我遇到的整个案例中也使用了这个例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM