当前位置:网站首页>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')
Map
give 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
边栏推荐
- LeetCode 241. 为运算表达式设计优先级(分治/记忆化递归/动态规划)
- Steam教育的实际问题解决能力
- 线程池批量处理数据
- 案例分享|智慧化的西部机场
- Gee: explore the characteristics of precipitation change in the Yellow River Basin in the past 10 years [pixel by pixel analysis]
- Go GC garbage collection notes (three color mark)
- Fabric.js 渐变
- Lay the foundation for children's programming to become a basic discipline
- 7.TCP的十一种状态集
- 摆正元素(带过渡动画)
猜你喜欢
Ansible installation and use
Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel
el form 表单validate成功后没有执行逻辑
Fabric.js 激活输入框
Fabric.js 精简JSON
[common error] the DDR type of FPGA device is selected incorrectly
Steam教育的实际问题解决能力
将光盘中的cda保存到电脑中
Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]
About PROFIBUS: communication backbone network of production plant
随机推荐
运维工作的“本手、妙手、俗手”
数据库问题汇总
Fabric.js 将本地图像上传到画布背景
Fabric.js 基础笔刷
Dark horse notes -- map set system
C # picture display occupancy problem
关于Steam 教育的知识整理
[quick view opencv] familiar with CV matrix operation with image splicing examples (3)
leetcode两数相加go实现
Global and Chinese market of travel data recorder (VDR) 2022-2028: Research Report on technology, participants, trends, market size and share
Nodejs (03) -- custom module
6.网络-基础
Leetcode 18 problem [sum of four numbers] recursive solution
Fabric.js 背景不受视口变换影响
7.1模擬賽總結
There are duplicate elements in leetcode. Go implementation
Mathematical problems (number theory) trial division to judge prime numbers, decompose prime factors, and screen prime numbers
从数组中找出和为目标的下标
How to make an RPM file
Knowledge arrangement about steam Education