hubei——shp
链接:https://pan.baidu.com/s/1mTVj8-xTNsx9X3dKX-w6QQ?pwd=nvu5
提取码:nvu5
用法 | |
---|---|
创建 | ee.Geometry.Point()、ee.Geometry.Multipoint() |
几何 | geometry.transform()、geometry.centroid()、geometry.simplify()、geometry.bounds()、geometry.buffer()、geometry.union() |
查询 | geometry.geometries()、geometry.coordinates()、geometry.length()、geometry.area()、geometry.perimeter()、geometry.distance() |
转换 | geometry.toGeoJSON() |
geometry–形状
包括:点、线、面
var Forbidden_City = ee.Geometry.Point(116.3968,39.9186)
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City = ee.Geometry.MultiPoint(
[[116.3921,39.9224],
[116.4014,39.9227],
[116.4017,39.9138],
[116.3929,39.9135]])
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City = ee.Geometry.LineString(
[[116.39234040929296,39.91321497621612],
[116.39195417119481,39.92276018488313],
[116.40186761571385,39.9230234821268],
[116.40216802312352,39.91354414349019]]);
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City = ee.Geometry.MultiLineString(
[[[116.39367078496434,39.92134494485143],
[116.39899228764989,39.92173989850053]],
[[116.39401410771825,39.91953471147776],
[116.39693235112645,39.92085124958646]],
[[116.39628862096288,39.91920557299557],
[116.39873479558446,39.91752694212849]]]);
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City = ee.Geometry.LinearRing(
[[116.39242623998143,39.91321497621612],
[116.39195417119481,39.92269436041402],
[116.40178178502538,39.9230234821268],
[116.40212510777928,39.91357706013058],
[116.39242623998143,39.91321497621612]]);
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City =ee.Geometry.MultiLineString(
[[[116.39320681392098,39.921786784372976],
[116.39337847529794,39.92040443758097],
[116.39578173457528,39.92070065709998],
[116.39556715785409,39.92188552236169],
[116.39320681392098,39.921786784372976]],
[[116.39801333247567,39.91918663276216],
[116.39548132716561,39.91777131887048],
[116.4006311684742,39.91747508667966],
[116.39801333247567,39.91918663276216]]]);
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City =ee.Geometry.Polygon(
[[[116.39239142238046,39.913146659084674],
[116.40209029017831,39.91354166001771],
[116.40170405208016,39.922988086896794],
[116.39183352290536,39.922593140447425]]])
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City =ee.Geometry.Polygon([
[[116.39179060756112,39.922576684295926],
[116.39230559169198,39.913064366936894],
[116.40213320552255,39.91352520169099],
[116.40161822139169,39.92297163084022]],
[[116.39483759700204,39.91961451259886],
[116.39496634303475,39.91648763678902],
[116.39900038539315,39.916553467224674],
[116.39874289332772,39.91977908105491]]]);
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City = ee.Geometry.MultiPolygon(
[[[[116.39393637477303,39.921260179361866],
[116.39350722133065,39.91882457850439],
[116.39676878749276,39.918791664386056],
[116.39711211024667,39.920963962263336]]],
[[[116.39887163936044,39.91810046424626],
[116.39595339595223,39.91698136351405],
[116.40080282985116,39.91652055201477]]]]);
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
var Forbidden_City = ee.Geometry.Rectangle(116.3926,39.9133,
116.4014,39.9227)
Map.centerObject(Forbidden_City)
print(Forbidden_City)
Map.addLayer(Forbidden_City)
https://epsg.io
先框定一个范围,分别以地理坐标系和投影坐标系来表示(感觉我理解的不正确)
var China_Geo = ee.Geometry.Rectangle(65.9,19.8,134.5,50.9)
var China_Planar = ee.Geometry(China_Geo, null, false)
var China_Planar_2 = China_Geo.transform('EPSG:4326', ee.ErrorMargin(100))
Map.addLayer(China_Geo,{color: 'FF0000'}, 'geodesic polygon')
Map.addLayer(China_Planar,{color: '000000'}, 'planar polygon')
Map.addLayer(China_Planar_2,{color : '0000CD'},'planar polygon2')
var China_Geo = ee.Geometry.Rectangle(65.9,19.8,134.5,50.9)
var China_Certer = China_Geo.centroid()
Map.addLayer(China_Geo,{color: 'FF0000'},'geodesic polygon')
Map.addLayer(China_Certer)
100km
var hubei = ee.FeatureCollection("users/szliu1120/hubei").geometry()
var hubei_sim = youyi.simplify(100000) #100000km
Map.centerObject(hubei)
Map.addLayer(hubei)
Map.addLayer(hubei_sim)
var hubei = ee.FeatureCollection("users/szliu1120/hubei").geometry()
var hubei_bound = hubei.bounds()
var hubei_hall = hubei.convexHull()
Map.centerObject(hubei)
Map.addLayer(hubei)
Map.addLayer(hubei_bound)
Map.addLayer(hubei_hall)
bounds的结果是一个矩形
convexHull的结果是一个凸边形
var hubei = ee.FeatureCollection("users/szliu1120/hubei").geometry()
var hubei_buffer = hubei.buffer(100000)
Map.centerObject(hubei)
Map.addLayer(hubei)
Map.addLayer(hubei_buffer)
intersection
symmetricDifference 对称求反
Difference 求反
var Polygon_1 = ee.Geometry.Polygon(
[[[152.71032334056088,18.862610207551867],
[-170.72717665943918,19.69222816299581],
[-171.07873915943918,40.62061002589569],
[153.41344834056088,40.08478212000696]]]),
Polygon_2 = ee.Geometry.Polygon(
[[[-176.52795790943912,45.620172046005735],
[-176.70373915943912,32.2945468815855],
[-142.60217665943918,32.2945468815855],
[-141.02014540943918,45.49709377875777]]]);
var Polygon_union = Polygon_1.union(Polygon_2);
Map.centerObject(Polygon_1)
Map.addLayer(Polygon_1)
Map.addLayer(Polygon_2)
Map.addLayer(Polygon_union)
将多面分解为两个单面
var Forbidden_City = ee.Geometry.MultiPolygon(
[[[[116.39393637477303,39.921260179361866],
[116.39350722133065,39.91882457850439],
[116.39676878749276,39.918791664386056],
[116.39711211024667,39.920963962263336]]],
[[[116.39887163936044,39.91810046424626],
[116.39595339595223,39.91698136351405],
[116.40080282985116,39.91652055201477]]]])
var Geometry_List = Forbidden_City.geometries()
Map.centerObject(Forbidden_City)
Map.addLayer(Forbidden_City)
print(Forbidden_City)
print(Geometry_List)
分别是中空的面积和实心的面积
var Polygon_1 =ee.Geometry.Polygon([
[[116.39179060756112,39.922576684295926],
[116.39230559169198,39.91352520169099],
[116.40213320552255,39.91352520169099],
[116.40161822139169,39.92297163084022]],
[[116.39483759700204,39.91961451259886],
[116.39496634303475,39.91648763678902],
[116.39900038539315,39.916553467224674],
[116.39874289332772,39.91977908105491]]])
var Polygon_2 =ee.Geometry.Polygon(
[[[116.39239142238046,39.913146659084674],
[116.40209029017831,39.91354166001771],
[116.40170405208016,39.922988086896794],
[116.39183352290536,39.922593140447425]]]);
var Area_1 = Polygon_1.area()
var Area_2 = Polygon_2.area()
var Perimeter_1 = Polygon_1.perimeter()
var Perimeter_2 = Polygon_2.perimeter()
print(Area_1,Area_2,Perimeter_1,Perimeter_2)
Map.centerObject(Polygon_1)
Map.addLayer(Polygon_1)
Map.addLayer(Polygon_2)
最近的两个点的距离
var geometry_1 = ee.Geometry.Polygon(
[[[116.39419386683858,39.92130954875369],
[116.39359305201924,39.918873949652266],
[116.3966829568044,39.918709379020974],
[116.39719794093526,39.92101333186874]]]),
geometry_2 = ee.Geometry.Polygon(
[[[116.39891455470479,39.918116921473526],
[116.3957817345754,39.917063650955505],
[116.40123198329366,39.91647117917021]]])
var Distance = geometry_1.distance(geometry_2)
print(Distance)
Map.centerObject(geometry_1)
Map.addLayer(geometry_1)
Map.addLayer(geometry_2)
var geometry = ee.Geometry.Polygon(
[[[116.39419386683858,39.92130954875369],
[116.39359305201924,39.918873949652266],
[116.3966829568044,39.918709379020974],
[116.39719794093526,39.92101333186874]]])
var geometry_GeoJSON = geometry.toGeoJSON()
print(geometry)
print(geometry_GeoJSON)
Map.centerObject(geometry)
Map.addLayer(geometry)
包含了更多的信息量,还包含如人口、GDP等属性信息
用法 | 语法 |
---|---|
创建 | Feature.select()、 Feature.transform、 Feature.set/setMulti |
几何 | Feature.centroid、 Feature.simplify、 Feature.bounds、 Feature.convexHull、 Feature.buffer、 Feature.union、 Feature.intersection、 Feature.difference、 Feature.symmetricDifference |
提取 | Feature.geometry、 Feature.get、 Feature.Length、 Feature.Area、 Feature.Perimeter |
var Forbidden_City =ee.Geometry.Polygon(
[[[116.39239142238046,39.913146659084674],
[116.40209029017831,39.91354166001771],
[116.40170405208016,39.922988086896794],
[116.39183352290536,39.922593140447425]]])
var Feature_Fobidden_City = ee.Feature(Forbidden_City,{name:'故宫', location:'北京'})
Map.centerObject(Forbidden_City)
print(Feature_Fobidden_City)
Map.addLayer(Feature_Fobidden_City)
保留的是空间数据和选择的属性
var Forbidden_City =ee.Geometry.Polygon(
[[[116.39239142238046,39.913146659084674],
[116.40209029017831,39.91354166001771],
[116.40170405208016,39.922988086896794],
[116.39183352290536,39.922593140447425]]]);
var Feature_Fobidden_City = ee.Feature(Forbidden_City, {name:'故宫', location:'北京'})
var Feature_select = Feature_Fobidden_City.select(['name'])
Map.centerObject(Forbidden_City)
print(Feature_Fobidden_City, Feature_select)
Map.addLayer(Feature_Fobidden_City)
将某一种坐标系转换为另一种坐标系
以经纬度为单位的坐标系无法计算面积
var China_Geo = ee.Feature(ee.Geometry.Rectangle(65.9,19.8,134.5,50.9))
var China_Plnar = China_Geo.transform('EPSG:3857',ee.ErrorMargin(100))
print(ee.Geometry(China_Geo.geometry()).projection(),
ee.Geometry(China_Plnar.geometry()).projection())
var Forbidden_City =ee.Geometry.Polygon(
[[[116.39239142238046,39.913146659084674],
[116.40209029017831,39.91354166001771],
[116.40170405208016,39.922988086896794],
[116.39183352290536,39.922593140447425]]]);
var Feature_Fobidden_City = ee.Feature(Forbidden_City, {name:'故宫', location:'北京'})
var Feature_Set = Feature_Fobidden_City.set('name','Gugong', 'location', "Beijing")
print(Feature_Fobidden_City,Feature_Set)
Map.centerObject(Forbidden_City)
Map.addLayer(Feature_Fobidden_City)
此处省略
var hubei = ee.Feature(ee.FeatureCollection("users/szliu1120/hubei").first())
var hubei_geometry = hubei.geometry()
var hubei_get = hubei.get('name')
print(hubei,hubei_geometry,hubei_get)
var hubei = ee.Feature(ee.FeatureCollection("users/szliu1120/hubei").first())
var hubei_area = hubei.area()
var hubei_perimeter = hubei.perimeter()
print(hubei,hubei_area,hubei_perimeter)
Feature的集合
功能 | 语法 |
---|---|
创建 | GE自带、上传、FushionTable、ee.FeatureCollection 、randomPoints |
编辑 | filterMetadata、limit、filterDate、filterBounds、filter、select、distinct、union、merge、set、remap、sort、makeArray |
转换 | geometry、reduceToImage |
查询 | first、toList、aggregate_first、aggregate_array |
统计 | aggregate_ststs、_histogram、_count、_count_distinct、aggregate_max、_min、_sum、_mean、_product、aggregate_sample_var、_total_var、_sample_sd、_total_sd |
其他 | map |
var Poly = ee.Geometry.Polygon(
[[[116.39248531478768,39.91319513792091],
[116.40222709792977,39.91378763804685],
[116.40184085983162,39.92303655876662],
[116.39171283859139,39.922674524864675]]])
var Points = ee.Geometry.MultiPoint(
[[116.38823669570809,39.92079850034943],
[116.38677757400399,39.91885659627606],
[116.38669174331551,39.916881722097074],
[116.38767879623299,39.91421555161684]])
var Lines = ee.Geometry.LineString(
[[116.37733619827156,39.9167171466781],
[116.38192814010506,39.91754001981801],
[116.37712162155037,39.91365597179514],
[116.38424556869393,39.914478881715695]])
var Feature_Collection = ee.FeatureCollection( [Poly, Points, Lines] );
Map.centerObject(Feature_Collection)
print (Feature_Collection)
Map.addLayer (Feature_Collection)
var Poly = ee.Geometry.Polygon(
[[[116.39248531478768,39.91319513792091],
[116.40222709792977,39.91378763804685],
[116.40184085983162,39.92303655876662],
[116.39171283859139,39.922674524864675]]])
var Random_Points = ee.FeatureCollection.randomPoints(Poly,20)
Map.centerObject(Poly)
Map.addLayer(Poly)
Map.addLayer(Random_Points)
略
var Proction_Area = ee.FeatureCollection("WCMC/WDPA/current/polygons")
var Proction_Area_China = Proction_Area.filterMetadata('ISO3','equals','CHN')
Map.centerObject(Proction_Area_China)
Map.addLayer(Proction_Area_China,{color:'FF0000'})
var hubei = ee.FeatureCollection("users/szliu1120/hubei");
Map.addLayer(hubei)
Map.addLayer(hubei.limit(5,'ADcose',false))# False 从小到大
最多支持打印500个
var S2 = ee.ImageCollection("COPERNICUS/S2");
var Sentinel_FilterDate = S2.filterDate('2019-03-01','2019-03-16').limit(50)
print(Sentinel_FilterDate)
var hubei = ee.FeatureCollection("users/szliu1120/hubei")
var wuhan_point =ee.Geometry.Point([114.522029,30.510227])
var wuhan =hubei.filterBounds(wuhan_point)
Map.centerObject(hubei)
Map.addLayer(hubei)
Map.addLayer(wuhan,{color:'FF0000'})
var hubei = ee.FeatureCollection("users/szliu1120/hubei")
var wuhan_point =ee.Geometry.Point([114.522029,30.510227])
var filter_by_hubei = ee.Filter.bounds(wuhan_point)
var wuhan = hubei.filter(filter_by_hubei)
Map.centerObject(hubei)
Map.addLayer(hubei)
Map.addLayer(wuhan,{color:'FF0000'})
filter有很多用法
去除重复字段
将featureCollection的空间属性融合
重复或覆盖属性信息
对每个属性进行相应操作
true:从小到大
False:从大到小
var China_Provinces = ee.FeatureCollection("users/wangjinzhulala/China_Provinces").limit(3);
var China_Array = China_Provinces.makeArray(['OBJECTID','Shape_Area','Shape_Leng'],'An_Array')
print(China_Provinces)
print(China_Array)
var China_Provinces = ee.FeatureCollection("users/wangjinzhulala/China_Provinces").limit(3)
var China_Geometry = China_Provinces.geometry()
print(China_Provinces)
print(China_Geometry)
矢量转栅格
var China_Provinces = ee.FeatureCollection("users/wangjinzhulala/China_Provinces")
var China_Biggest_Province = ee.Feature(China_Provinces.sort('Shape_Area',false).first())
print(China_Biggest_Province)
Map.centerObject(China_Provinces,4)
Map.addLayer(China_Biggest_Province)
var China_Provinces = ee.FeatureCollection("users/wangjinzhulala/China_Provinces")
var China_Biggest_Province = ee.Feature(China_Provinces.sort('Shape_Area',false).first())
print(China_Biggest_Province)
Map.centerObject(China_Provinces,4)
Map.addLayer(China_Biggest_Province)
用于选几个区域
var hubei = ee.FeatureCollection("users/szliu1120/hubei")
var hubei_list = hubei.sort('adcode',false).toList(5)
print(hubei_list)
var Area_No_1 = ee.Feature(hubei_list.get(0))
var Area_No_3 = ee.Feature(hubei_list.get(2))
var Area_No_4 = ee.Feature(hubei_list.get(4))
Map.centerObject(hubei)
Map.addLayer(Area_No_1)
Map.addLayer(Area_No_3)
Map.addLayer(Area_No_4)
对属性表的某一列进行操作
var hubei = ee.FeatureCollection("users/szliu1120/hubei")
var code_first = hubei.sort('adcode',false).aggregate_first('adcode')
print(code_first)
var hubei = ee.FeatureCollection("users/szliu1120/hubei")
var code_first = hubei.sort('adcode',false).limit(3).aggregate_array('adcode')
print(code_first)
var hubei = ee.FeatureCollection("users/szliu1120/hubei")
function Add_Center(feature){
return feature.centroid()
}
var hubei_center = hubei.map(Add_Center)
print(hubei_center)
Map.centerObject(hubei)
Map.addLayer(hubei)
Map.addLayer(hubei_center,{color:'ff0000'})