当前位置:网站首页>Gee: create a new feature and set corresponding attributes
Gee: create a new feature and set corresponding attributes
2022-07-02 05:12: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
边栏推荐
- 删除排序数组中的重复项go语言实现
- leetcode两数相加go实现
- 2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
- Express logistics quick query method, set the unsigned doc No. to refresh and query automatically
- National all Chinese Automatic Test Software apifox
- JS interview collection test question 1
- Pyechart1.19 national air quality exhibition
- Global and Chinese market of travel data recorder (VDR) 2022-2028: Research Report on technology, participants, trends, market size and share
- Feign realizes file uploading and downloading
- Global and Chinese market of commercial fish tanks 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢

Collectors. Groupingby sort
![[common error] the DDR type of FPGA device is selected incorrectly](/img/f3/be66bcfafeed581add6d48654dfe34.jpg)
[common error] the DDR type of FPGA device is selected incorrectly

Record my pytorch installation process and errors

Steam教育的实际问题解决能力

Future trend of automated testing ----- self healing technology

Precipitate yourself and stay up late to sort out 100 knowledge points of interface testing professional literacy

Video cover image setting, put cover images into multiple videos in the simplest way

The El cascader echo only selects the questions that are not displayed

Disable access to external entities in XML parsing

Fabric.js IText 上标和下标
随机推荐
6.网络-基础
Implementation of leetcode two number addition go
7.TCP的十一种状态集
Fabric.js IText 手动设置斜体
Mysql重点难题(2)汇总
Global and Chinese market of travel data recorder (VDR) 2022-2028: Research Report on technology, participants, trends, market size and share
Mathematical knowledge (Euler function)
Set the default style of scroll bar Google browser
Johnson–Lindenstrauss Lemma(2)
数据库问题汇总
Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel
Pyflink writes MySQL examples with JDBC
go实现leetcode旋转数组
Fabric.js IText 上标和下标
关于Steam 教育的知识整理
删除排序数组中的重复项go语言实现
fastText文本分类
MMAP zero copy knowledge point notes
LeetCode 241. 为运算表达式设计优先级(分治/记忆化递归/动态规划)
2022阿里巴巴全球数学竞赛 第4题 虎虎生威(盲盒问题、集卡问题)解决思路