GeoPandas 网站上的这个官方示例显示了一个示例 geopandas 数据框,其中的列geometry包含POLYGON坐标:
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 具有投影到特定坐标参考系统 (CRS) 的空间数据,该坐标参考系统不是纬度/经度。纬度和经度坐标需要对地球形状和参考零点进行特定定义 - 最常被接受为标准的是世界大地测量系统 1984(又名WGS84aka EPSG:4326)。很多时候,当您加载 Shapefile 时,数据将使用 WGS84 编码为纬度/经度。但并非总是如此。
WGS84
EPSG:4326
或.crs的属性提供了有关用于编码数据的特定参考系统的更多信息。在此示例中:GeoDataFrame``GeoSeries
.crs
GeoDataFrame``GeoSeries
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
您可以看到,此数据集中的坐标以美国测量英尺为单位,参考北美基准 1983 (NAD83)(因此值较大),并使用兰伯特圆锥共形 (2SP)投影进行投影。此投影在制图方面具有优势,因为与等距矩形投影不同(例如,简单地将纬度/经度映射到像素),共形投影将保留角度(因此,无论纬度如何,街道拐角看起来都是直角)。
您可以使用 更改投影geopandas.GeoDataFrame.to_crs。GeoPandaspyproj用于管理投影 - WGS84 的 proj 语法是"epsg:4326":
geopandas.GeoDataFrame.to_crs
pyproj
"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
现在,形状以纬度/经度表示
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 ...