为什么我的 geopandas 形状文件中的区域为零?

问题描述 投票:0回答:1

我在 Python 中,我有一个已加载到数据框(日期)中的形状文件。当我打印 data[['geometry'].head() 时,您可以看到 GPS 坐标打印在终端中。但是当我尝试计算多边形的面积时,我得到零值 (0.0000)。

这是为什么?

Import necessary modules
import geopandas as gpd

#Read file using gpd.read_file()
data = gpd.read_file("/kaggle/input/aeso-connection-list/Apr_2023_ProjectList_Shapefile.shp")

print(data.head(2))

print(data['geometry'].head())

#Make a selection that contains only the first five rows
selection = data[0:5]

#Iterate over rows and print the area of a Polygon 
for index, row in selection.iterrows():
    #Get the area of the polygon
    poly_area = row['geometry'].area
    #Print information for the user
    print("Polygon area at index {index} is: {area:.3f}".format(index=index, area=poly_area))

#终端输出 #***************************************

             Status_1                                 Project_Na  ProjNo  \
0  Recently Cancelled  P1505 ATCO City of Grande Prairie New POD  1505.0   
1              Active           P1567 EDPR Sharp Hills Wind Farm  1567.0   

          Planning_1  Project_Ty MW_Type  Stage_1 Disclaimer Inclusion  \
0  20-Grande Prairie  Connection    Load      5.0       None       Yes   
1           42-Hanna  Connection    Wind      5.0       None       Yes   

   Applied_On  ...     EN1_ISD  EN2_STS_MW EN2_DTS_MW       EN2_ISD  \
0  2013-12-10  ...        None        None       None          None   
1  2014-06-04  ...  2023-02-10         289          0  Aug 15, 2023   

                         EN2 EN3_STS_MW EN3_DTS_MW EN3_ISD EN3  \
0                         NA       None       None    None  NA   
1  289 MW STS - Aug 15, 2023       None       None    None  NA   

#************************************

                      geometry  
0  POINT (-118.87506 55.21973)  
1  POINT (-110.63801 51.73891)  
[2 rows x 22 columns]

#*************************************
0    POINT (-118.87506 55.21973)
1    POINT (-110.63801 51.73891)
2    POINT (-113.51863 53.52077)
3    POINT (-113.31835 51.88593)
4    POINT (-110.90825 53.97699)

#*************************************
Polygon area at index 0 is: 0.000
Polygon area at index 1 is: 0.000
Polygon area at index 2 is: 0.000
Polygon area at index 3 is: 0.000
Polygon area at index 4 is: 0.000

python geometry geopandas
1个回答
0
投票

如果我添加 print(row[‘geometry’]) 我会得到以下内容。

点 (-118.8750601446094 55.21973332493394) 点 (-110.6380147081117 51.73891179004801) 点 (-113.5186281806454 53.52076863506539) 点 (-113.3183451958735 51.88593045532718) 点(-110.9082498754308 53.97698708098994)

© www.soinside.com 2019 - 2024. All rights reserved.