当前位置:网站首页>Gee: create a new feature and set corresponding attributes
Gee: create a new feature and set corresponding attributes
2022-07-04 01:05:00 【Gee water ecological space】
Although patience and persistence is a painful thing, but it can gradually bring you good.—— Ovid
Patience and persistence are painful things , But it can gradually bring you benefits .—— Ovid
One 、 problem
Earth Engine One of them Feature Is defined as GeoJSON features . say concretely ,a Feature Yes. geometry Storage Geometry object ( or null) Of properties Attributes and objects that store attributes of other attribute dictionaries .
But how in GEE Create a Feature, And assign corresponding attributes to it ?
Two 、 Function and usage
- ee.Feature()

3、 ... and 、 Examples of operation
1、 Create an empty Feature
python The code is as follows :
# Feature Unwanted a Geometry And you can simply wrap an attribute dictionary
# This situation can be applied to the analysis of data , Creating features in this way is important for exporting
# have Dictionary result ( for example image.reduceRegion()) Long running calculations of are very useful .
dict = {'foo':ee.Number(8).add(88), 'bar':'nihao'}
numFeature = ee.Feature(None, dict)
numFeature.getInfo()2、 Create a Geometry And attribute Feature
python The code is as follows :
# Earth Engine Medium AFeature Is defined as GeoJSON features . say concretely ,aFeature Yes. geometry Storage Geometry object ( or null) Of properties Attributes and objects that store attributes of other attribute dictionaries .
# To create a a Feature, Please provide the constructor Geometry and ( Optional ) Dictionary of other attributes
polygon = ee.Geometry.Polygon([[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]])
polyFeature = ee.Feature(polygon, {'foo':42, 'bar':'tart'})
Map = geemap.Map()
Map.addLayer(polyFeature, {}, 'Feature')
Mapgive the result as follows :

3、 by Feature Add attributes and queries
python The code is as follows :
# Every Feature There is one. Geometry Stored in geometry The master node in the attribute . Other geometry can be stored in other attributes .
# Geometry There are also methods such as intersections and buffers , Feature To facilitate access to the main object Geometry, Apply the operation and set the result to the new main object Geometry.
# The result will be preserved Feature Call all other properties of this method . There are also some ways to get and set Feature.
feature = ee.Feature(ee.Geometry.Point([-122.22599, 37.17605])) \
.set('genus', 'Pine') \
.set('species', 'Green')
prop1 = feature.get('species')
print(prop1.getInfo())
# Set new properties
feature = feature.set('presence', 1)
prop2 = feature.get('presence')
print(prop2.getInfo())Four 、 Summary
- utilize ee.Feature() It can be easily realized Feature The creation of , use set Method to add the attribute dictionary to the attribute , utilize get() Method to query the corresponding attribute
- You need to understand how to create an empty Feature Methods , Use this method to combine ee.reduceRegion() It can flexibly realize the processing and analysis of time series results .
Reference resources :
- https://developers.google.com/earth-engine/apidocs/ee-feature?hl=en
- https://developers.google.com/earth-engine/guides/features
- https://github.com/giswqs/earthengine-py-notebooks/blob/master/FeatureCollection/creating_feature.ipynb
边栏推荐
- 关于 uintptr_t和intptr_t 类型
- About uintptr_ T and IntPtr_ T type
- Day05 table
- 查询效率提升10倍!3种优化方案,帮你解决MySQL深分页问题
- GUI application: socket network chat room
- 我管你什么okr还是kpi,PPT轻松交给你
- 功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
- be based on. NETCORE development blog project starblog - (14) realize theme switching function
- Function: find the sum of the elements on the main and sub diagonal of the matrix with 5 rows and 5 columns. Note that the elements where the two diagonals intersect are added only once. For example,
- [cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept
猜你喜欢

Windos10 reinstallation system tutorial

How to use AHAS to ensure the stability of Web services?

MySQL winter vacation self-study 2022 12 (1)

Technical practice online fault analysis and solutions (Part 1)

Thinkphp6 integrated JWT method and detailed explanation of generation, removal and destruction

Introduction to A-frame virtual reality development

2-redis architecture design to use scenarios - four deployment and operation modes (Part 2)

Gauss elimination method and template code

Cloud dial test helps Weidong cloud education to comprehensively improve the global user experience

功能:求出菲波那契数列的前一项与后一项之比的极限的 近似值。例如:当误差为0.0001时,函数值为0.618056。
随机推荐
8. Go implementation of string conversion integer (ATOI) and leetcode
数据库表外键的设计
Sequence list and linked list
Day05 table
手机异步发送短信验证码解决方案-Celery+redis
Delete all elements with a value of Y. The values of array elements and y are entered by the main function through the keyboard.
Gauss elimination method and template code
Avoid playing with super high conversion rate in material minefields
Optimization of for loop
From functional testing to automated testing, how did I successfully transform my salary to 15K +?
机器学习基础:用 Lasso 做特征选择
CesiumJS 2022^ 源码解读[8] - 资源封装与多线程
From functools import reduce -- see the use of reduce function from typical examples
Function: find the approximate value of the limit of the ratio of the former term to the latter term of Fibonacci sequence. For example, when the error is 0.0001, the function value is 0.618056.
mysql使用视图报错,EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
[common error] UART cannot receive data error
How to use AHAS to ensure the stability of Web services?
C library function int fprintf (file *stream, const char *format,...) Send formatted output to stream
Anomalies seen during the interview