【Geopandas】提取组成Polygon对象的点的坐标
·
思路
先将geometry转为json格式,再从json中提取各个多边形的点的坐标
代码
import geopandas as gs
import json
gdf = gs.read_file("F:\\Zhujie\\JY_Data\\test_blocks.shp")
polygon = gdf.geometry.to_json()
polygon_dict = json.loads(polygon)
print(polygon_dict["features"][0]["geometry"]["coordinates"][0])
如果你认为对你有用,关注我的微信公众号支持我一下吧!~

Polygon的JSON格式示意
{
"type":"FeatureCollection",
"features":[
{
"id":"0",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
38252.22289886114,
26990.60187920509
],
[
38250.09489885916,
26956.393047173216
],
[
38183.25694679691,
26964.288855180555
],
[
38185.645106799144,
26993.967959208243
],
[
38252.22289886114,
26990.60187920509
]
]
]
},
"bbox":[
38183.25694679691,
26956.393047173216,
38252.22289886114,
26993.967959208243
]
},
{
"id":"1",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
38373.378098973975,
26911.757975131688
],
[
38370.98981097175,
26879.424855101566
],
[
38369.98712297081,
26868.49704709137
],
[
38373.1820029738,
26863.740055086964
],
[
38370.804018971576,
26831.978839057385
],
[
38350.94891495308,
26834.60283905978
],
[
38342.8060029455,
26835.522967060682
],
[
38331.841010935284,
26837.474967062473
],
[
38312.72504291748,
26842.325847067
],
[
38299.58981090525,
26847.145879071497
],
[
38278.116914885264,
26856.62197508029
],
[
38249.999922859075,
26869.438039092234
],
[
38240.701042850415,
26873.543063096065
],
[
38240.55710685026,
26878.99688710115
],
[
38243.767154853274,
26900.2259431209
],
[
38267.71089887556,
26898.191959118998
],
[
38267.90795487576,
26906.130071126394
],
[
38271.71211487929,
26905.47394312581
],
[
38275.20209888255,
26934.057047152426
],
[
38343.19390694588,
26926.083991145017
],
[
38363.4371069647,
26923.574871142686
],
[
38365.942002967065,
26923.001943142153
],
[
38367.549042968545,
26922.231959141383
],
[
38368.9028989698,
26921.338967140593
],
[
38370.57489897136,
26919.62683913898
],
[
38372.60011497327,
26916.786071136365
],
[
38373.408114974016,
26914.840983134523
],
[
38373.378098973975,
26911.757975131688
]
]
]
},
"bbox":[
38240.55710685026,
26831.978839057385,
38373.408114974016,
26934.057047152426
]
},
{
"id":"2",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
38620.64805120428,
26735.126870967157
],
[
38651.991155233445,
26628.959062868264
],
[
38634.49912321716,
26631.0398948702
],
[
38627.37489921053,
26630.73704686994
],
[
38603.38200318819,
26736.172950968146
],
[
38605.10110718978,
26757.667990988182
],
[
38620.62590720423,
26757.05506298755
],
[
38621.88504320541,
26750.163094981166
],
[
38618.55480320231,
26745.590870976917
],
[
38620.64805120428,
26735.126870967157
]
]
]
},
"bbox":[
38603.38200318819,
26628.959062868264,
38651.991155233445,
26757.667990988182
]
},
{
"id":"3",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
38112.52190673104,
26999.999895213812
],
[
38112.97790673145,
26993.89883920818
],
[
38112.024114730564,
26993.981079208257
],
[
38111.82801873039,
26993.166999207464
],
[
38111.12504272973,
26991.079063205514
],
[
38110.1279227288,
26989.042071203647
],
[
38108.91915472769,
26987.214999201944
],
[
38107.825010726665,
26985.911959200694
],
[
38106.72011472565,
26984.82395919971
],
[
38105.04190672408,
26983.494039198442
],
[
38103.407922722545,
26982.487959197548
],
[
38101.443122720724,
26981.579863196705
],
[
38100.1428987195,
26981.13499919628
],
[
38098.80990671826,
26980.79496719595
],
[
38052.62705867525,
26983.533975198516
],
[
38053.00190667561,
27009.18799122243
],
[
38111.95301073051,
27006.02997521946
],
[
38112.52190673104,
26999.999895213812
]
]
]
},
"bbox":[
38052.62705867525,
26980.79496719595,
38112.97790673145,
27009.18799122243
]
},
{
"id":"4",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
38533.143155122765,
26945.192087162814
],
[
38529.569011119434,
26921.68488714093
],
[
38453.76581104883,
26930.57499914919
],
[
38426.91000302383,
26933.875095152238
],
[
38421.73912301902,
26936.183959154412
],
[
38403.520115002066,
26938.403991156494
],
[
38401.90392300054,
26938.98997515702
],
[
38399.880050998654,
26940.222039158165
],
[
38398.12901099702,
26941.751959159566
],
[
38396.66801899567,
26943.456855161174
],
[
38395.733042994805,
26945.791895163362
],
[
38395.27512299436,
26947.31995916477
],
[
38395.27889899438,
26951.60687116877
],
[
38395.769906994836,
26958.92795917561
],
[
38533.143155122765,
26945.192087162814
]
]
]
},
"bbox":[
38395.27512299436,
26921.68488714093,
38533.143155122765,
26958.92795917561
]
},
{
"id":"5",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
38048.35691467129,
26956.212055173066
],
[
38045.519922668645,
26893.395095114538
],
[
37920.581810552285,
26902.367063122918
],
[
37856.90712249297,
26907.19394312741
],
[
37848.40504248505,
26907.19394312741
],
[
37796.31390643655,
26909.777047129817
],
[
37800.4481144404,
26973.62696718925
],
[
37956.30501058556,
26962.903959179297
],
[
38000.00011462625,
26959.802967176427
],
[
38048.35691467129,
26956.212055173066
]
]
]
},
"bbox":[
37796.31390643655,
26893.395095114538,
38048.35691467129,
26973.62696718925
]
},
{
"id":"6",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
38436.5231230328,
26616.0820708563
],
[
38403.58609900211,
26613.85506285419
],
[
38401.05201899973,
26615.158870855405
],
[
38400.297010999064,
26617.055894857214
],
[
38388.49310698806,
26703.350870937575
],
[
38387.08190698674,
26718.518870951666
],
[
38387.54200298718,
26719.934038952986
],
[
38389.27480298877,
26721.57787895453
],
[
38390.60901099001,
26722.219862955157
],
[
38405.42014700381,
26725.387862958072
],
[
38431.12990702777,
26729.58805496199
],
[
38487.129907079914,
26742.48687097401
],
[
38508.54104309986,
26748.319062979426
],
[
38512.27301110333,
26749.250966980297
],
[
38513.024115104025,
26749.26805498032
],
[
38520.2948991108,
26721.190038954202
],
[
38523.16811511349,
26710.90088694461
],
[
38472.581811066375,
26695.363990930142
],
[
38475.13304306876,
26669.073046905633
],
[
38470.81701106473,
26668.223062904843
],
[
38478.573107071956,
26619.252886859234
],
[
38436.5231230328,
26616.0820708563
]
]
]
},
"bbox":[
38387.08190698674,
26613.85506285419,
38523.16811511349,
26749.26805498032
]
},
{
"id":"7",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
37826.4300024646,
26479.412886729
],
[
37795.95390643622,
26473.526870723523
],
[
37778.86705842029,
26538.782038784295
],
[
37812.42405045155,
26545.236054790323
],
[
37826.4300024646,
26479.412886729
]
]
]
},
"bbox":[
37778.86705842029,
26473.526870723523,
37826.4300024646,
26545.236054790323
]
},
{
"id":"8",
"type":"Feature",
"properties":{
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
38409.10014700724,
26918.10088713758
],
[
38419.94981101735,
26916.692055136256
],
[
38420.949043018285,
26916.772951136347
],
[
38425.99889902299,
26917.591959137066
],
[
38434.38289903078,
26916.702039136264
],
[
38471.26712306513,
26912.29295113217
],
[
38512.73611510376,
26907.548055127732
],
[
38516.639475107404,
26907.09493512731
],
[
38523.68401911395,
26905.95599112625
],
[
38546.815475135496,
26902.78997512331
],
[
38579.11397116559,
26898.267031119092
],
[
38635.32901121793,
26892.027031113277
],
[
38644.80299522676,
26890.947991112305
],
[
38659.73022724066,
26889.296023110743
],
[
38689.58475526848,
26885.992023107654
],
[
38704.51198728238,
26884.339991106128
],
[
38705.460723283264,
26884.07483910589
],
[
38706.26225928401,
26883.695511105532
],
[
38707.14526728483,
26883.068119104955
],
[
38707.888627285516,
26882.280151104205
],
[
38708.59109128616,
26881.095639103096
],
[
38708.945395286486,
26879.968791102063
],
[
38709.052147286595,
26878.69384710089
],
[
38708.93297928648,
26877.71599109995
],
[
38709.35998728688,
26872.41999109503
],
[
38709.10897928666,
26861.97544708528
],
[
38708.85790728641,
26851.53083907557
],
[
38708.17790728578,
26814.79797504138
],
[
38606.12901119074,
26824.85595905071
],
[
38518.99301110959,
26834.456983059645
],
[
38512.345907103394,
26835.18888706033
],
[
38463.556915057976,
26842.514071067155
],
[
38455.31710705027,
26842.514071067155
],
[
38457.67089905247,
26823.416983049367
],
[
38447.33790704286,
26820.0159590462
],
[
38380.92811498101,
26806.144855033315
],
[
38383.051122982986,
26819.023959045302
],
[
38385.559154985334,
26853.855895077755
],
[
38389.93381098941,
26877.26197509951
],
[
38392.24190699155,
26907.69186312787
],
[
38392.90590699216,
26910.57295113057
],
[
38393.54181099276,
26912.020055131932
],
[
38394.47390699364,
26913.375895133184
],
[
38397.21400299616,
26915.55599113519
],
[
38400.17790699893,
26917.387863136886
],
[
38402.38705900099,
26918.243991137715
],
[
38404.34200300282,
26918.620055138075
],
[
38409.10014700724,
26918.10088713758
]
]
]
},
"bbox":[
38380.92811498101,
26806.144855033315,
38709.35998728688,
26918.620055138075
]
}
],
"bbox":[
37778.86705842029,
26473.526870723523,
38709.35998728688,
27009.18799122243
]
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)