当前位置:网站首页>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
边栏推荐
- The El cascader echo only selects the questions that are not displayed
- 2022阿里巴巴全球数学竞赛 第4题 虎虎生威(盲盒问题、集卡问题)解决思路
- LeetCode 1175. Prime number arrangement (prime number judgment + Combinatorial Mathematics)
- The underlying principle of go map (storage and capacity expansion)
- Fabric.js 精简JSON
- 2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
- Fabric.js 渐变
- Cultivate primary and secondary school students' love for educational robots
- JS interview collection test question 1
- ansible安装与使用
猜你喜欢

LeetCode 241. Design priorities for operational expressions (divide and conquer / mnemonic recursion / dynamic programming)

Mathematical problems (number theory) trial division to judge prime numbers, decompose prime factors, and screen prime numbers

Ansible installation and use

数学问题(数论)试除法做质数的判断、分解质因数,筛质数

2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas

paddle: ValueError:quality setting only supported for ‘jpeg‘ compression

Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel

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

Johnson–Lindenstrauss Lemma(2)

6.网络-基础
随机推荐
ansible安装与使用
黑马笔记---Set系列集合
Fabric.js 更换图片的3种方法(包括更换分组内的图片,以及存在缓存的情况)
Dark horse notes -- Set Series Collection
National all Chinese Automatic Test Software apifox
Global and Chinese market of hydrocyclone desander 2022-2028: Research Report on technology, participants, trends, market size and share
農業生態領域智能機器人的應用
6.网络-基础
Fabric.js 基础笔刷
案例分享|智慧化的西部机场
数据库问题汇总
设置滚动条默认样式 谷歌浏览器
No logic is executed after the El form is validated successfully
go实现leetcode旋转数组
Preparation for writing SAP ui5 applications using typescript
Johnson–Lindenstrauss Lemma(2)
Global and Chinese market of insulin pens 2022-2028: Research Report on technology, participants, trends, market size and share
数据库批量插入数据
7.1 Résumé du concours de simulation
农业生态领域智能机器人的应用