解释 GeoPandas 多边形坐标

Interpreting GeoPandas Polygon coordinates

GeoPandas 网站上的这个官方示例 here 显示了一个示例 geopandas 数据框,其中 geometry 列包含 POLYGON,坐标为:

               BoroName     Shape_Leng    Shape_Area  \
BoroCode
1             Manhattan  359299.096471  6.364715e+08
2                 Bronx  464392.991824  1.186925e+09
3              Brooklyn  741080.523166  1.937479e+09
4                Queens  896344.047763  3.045213e+09
5         Staten Island  330470.010332  1.623820e+09

                                                   geometry
BoroCode
1         MULTIPOLYGON (((981219.0557861328 188655.31579...
2         MULTIPOLYGON (((1012821.805786133 229228.26458...
3         MULTIPOLYGON (((1021176.479003906 151374.79699...
4         MULTIPOLYGON (((1029606.076599121 156073.81420...
5         MULTIPOLYGON (((970217.0223999023 145643.33221...

我是 GeoPandas 新手。我认为坐标应该遵循 GPS 的 GIS 标准。如果是这样,为什么这些坐标这么大(以百万为单位)。它们是否以某种方式扩大了规模?如果有人能解释一下,谢谢。

此 GeoDataFrame 具有投影到特定 coordinate reference system (CRS) which is not lat/lon. Latitude and Longitude coordinates need a specific definition of the shape of the earth and reference zero-points - one which is most commonly accepted as the standard is World Geodetic System 1984(又名 WGS84 又名 EPSG:4326)的空间数据。很多时候,当您加载 shapefile 时,数据将使用 WGS84 编码为 lat/lon。但并非总是如此。

GeoDataFrameGeoSeries.crs 属性提供了有关在编码数据时使用的特定参考系统的更多信息。在这个例子中:

In [3]: nybb_path = geopandas.datasets.get_path('nybb')
   ...: boros = geopandas.read_file(nybb_path)
   ...: boros.set_index('BoroCode', inplace=True)
   ...: boros.sort_index(inplace=True)
   ...: 

In [4]: boros.crs
Out[4]:
<Derived Projected CRS: EPSG:2263>
Name: NAD83 / New York Long Island (ftUS)
Axis Info [cartesian]:
- X[east]: Easting (US survey foot)
- Y[north]: Northing (US survey foot)
Area of Use:
- name: United States (USA) - New York - counties of Bronx; Kings; Nassau; New York; Queens; Richmond; Suffolk.
- bounds: (-74.26, 40.47, -71.8, 41.3)
Coordinate Operation:
- name: SPCS83 New York Long Island zone (US Survey feet)
- method: Lambert Conic Conformal (2SP)
Datum: North American Datum 1983
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

您可以看到此数据集中的坐标以 美国测量英尺 为单位,参考了 North American Datum 1983 (NAD83) (hence the large values), and are projected using a Lambert Conic Conformal (2SP) 投影。此投影具有映射优势,因为与 equi-rectangular 投影不同,例如简单地将 lat/lon 映射到像素,共形投影将保留角度(例如,无论纬度如何,街角看起来都是直角)。

您可以使用 geopandas.GeoDataFrame.to_crs. GeoPandas uses pyproj 更改投影来管理投影 - WGS84 的投影语法是 "epsg:4326":

In [5]: boros_latlon = boros.to_crs('epsg:4326')

In [6]: boros_latlon.crs
Out[6]: 
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

现在,形状表示为lat/lon

In [7]: boros_latlon
Out[7]: 
               BoroName     Shape_Leng    Shape_Area  \
BoroCode                                               
1             Manhattan  359299.096471  6.364715e+08   
2                 Bronx  464392.991824  1.186925e+09   
3              Brooklyn  741080.523166  1.937479e+09   
4                Queens  896344.047763  3.045213e+09   
5         Staten Island  330470.010332  1.623820e+09   

                                                   geometry  
BoroCode                                                     
1         MULTIPOLYGON (((-74.01093 40.68449, -74.01193 ...  
2         MULTIPOLYGON (((-73.89681 40.79581, -73.89694 ...  
3         MULTIPOLYGON (((-73.86706 40.58209, -73.86769 ...  
4         MULTIPOLYGON (((-73.83668 40.59495, -73.83678 ...  
5         MULTIPOLYGON (((-74.05051 40.56642, -74.05047 ... 

有关详细信息,请参阅 geopandas guide to projections and coordinate reference systems