欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Google Earth Engine(gee)中的Feature

程序员文章站 2022-05-26 19:13:38
...

目录

ee.Feature() 

Feature.select()

Feature中的set、setMulti

Feature.transform()

Feature.centroid/simplify/bounds/convexHull/buffer()

Feature.union/intersection/difference/symmetricDifference()

Feature中计算面积:area()、周长:perimeter()


 

ee.Feature() 

Google Earth Engine(gee)中的Feature

var geometry_tianfu= ee.Geometry.Polygon([[[104.06431420192233, 30.65820626544307],
                                          [104.06455023631564, 30.656581911340815],
                                          [104.06714661464206, 30.656581911340815],
                                          [104.06733973369113, 30.658372391028514]]])
              
var properties_tianfu=  {
          "name": "天府广场",
          "location": "成都",
          "system:index": "0"
        }     
        
var feature_tianfu =ee.Feature( geometry_tianfu,properties_tianfu);
print(feature_tianfu)

Map.centerObject(feature_tianfu)
Map.addLayer(feature_tianfu)

Feature.select()

提取出想要的属性,并给属性名改名

Google Earth Engine(gee)中的Feature

var geometry_tianfu= ee.Geometry.Polygon([[[104.06431420192233, 30.65820626544307],
                                          [104.06455023631564, 30.656581911340815],
                                          [104.06714661464206, 30.656581911340815],
                                          [104.06733973369113, 30.658372391028514]]])
              
var properties_tianfu=  {
          "name": "天府广场",
          "location": "成都",
          "system:index": "0"
        }     
        
var feature_tianfu =ee.Feature( geometry_tianfu,properties_tianfu);
print(feature_tianfu)
print(feature_tianfu.select(["name"]))
print(feature_tianfu.select(["name"],["名称"]))

Feature中的set、setMulti

Google Earth Engine(gee)中的Feature

var geometry_tianfu= ee.Geometry.Polygon([[[104.06431420192233, 30.65820626544307],
                                          [104.06455023631564, 30.656581911340815],
                                          [104.06714661464206, 30.656581911340815],
                                          [104.06733973369113, 30.658372391028514]]])
              
var properties_tianfu=  {
          "name": "天府广场",
          "location": "成都",
          "system:index": "0"
        }     
        
var feature_tianfu =ee.Feature( geometry_tianfu,properties_tianfu);
print(feature_tianfu)
print(feature_tianfu.set('location','chengdu'))
print(feature_tianfu.setMulti({'name':'chengdu','location':"tianfuguangchang"}))

Feature.transform()

Google Earth Engine(gee)中的Feature

print("myGeometry",myGeometry)

var feature=ee.Feature(myGeometry)
print("feature",feature)

var feature_transform=feature.transform('EPSG:3857',ee.ErrorMargin(100))
print("feature_transform",feature_transform)

print(ee.Geometry(feature.geometry()).projection())
print(ee.Geometry(feature_transform.geometry()).projection())

Feature.centroid/simplify/bounds/convexHull/buffer()

Google Earth Engine(gee)中的Feature

Google Earth Engine(gee)中的FeatureGoogle Earth Engine(gee)中的FeatureGoogle Earth Engine(gee)中的FeatureGoogle Earth Engine(gee)中的FeatureGoogle Earth Engine(gee)中的Feature

Feature.union/intersection/difference/symmetricDifference()

Google Earth Engine(gee)中的Feature

Google Earth Engine(gee)中的FeatureGoogle Earth Engine(gee)中的FeatureGoogle Earth Engine(gee)中的FeatureGoogle Earth Engine(gee)中的FeatureGoogle Earth Engine(gee)中的Feature

var feature1 =ee.Feature(ee.Geometry.Polygon(
            [[[103.43534679370603, 31.17014003162498],
              [102.90800304370603, 30.45777180538538],
              [103.71549816089353, 29.911716302186857],
              [104.48454112964353, 30.329839651564306],
              [104.03410167651853, 31.014908583940628]]]))
var feature2 = ee.Feature(ee.Geometry.Polygon(
            [[[104.44608898120603, 31.04785765490257],
              [103.91325206714353, 30.63281369239727],
              [104.30326671558103, 29.959319376777437],
              [105.34147472339353, 30.044947475833734]]]));
              

Map.centerObject(feature1)
Map.addLayer(feature1,{color:"00ffff"},"feature1")
Map.addLayer(feature2,{color:"32CD32"},"feature2")


Map.addLayer(feature1.union((feature2)),{},"union")
Map.addLayer(feature1.intersection((feature2)),{},"intersection")
Map.addLayer(feature1.difference((feature2)),{},"difference")
Map.addLayer(feature1.symmetricDifference((feature2)),{},"symmetricDifference")

Feature中计算面积:area()、周长:perimeter()

  • area():面积函数
  • perimeter():周长函数

Google Earth Engine(gee)中的Feature

print(sichuan)
print(sichuan.first())
print("面积",ee.Feature(sichuan.first()).area())
print("周长",ee.Feature(sichuan.first()).perimeter())