在 Geopandas 中转换 shapefile 的坐标

Convert the coordinates of a shapefile in Geopandas

我是空间分析的新手,但我无法在任何地方找到这个答案。

我有一个 CRS 坐标、纬度和经度的 post 代码列表,以及 OSN 坐标中的伦敦自治市镇形状文件,我想将它们映射在一起,但事实就是这样。这是 postcodes

的头部
london_post_codes.head()
Out[81]:
postcode    latitude    longitude
0   WD6 1GS 51.658021   -0.255663
1   WD17 1LA    51.660366   -0.397525
2   WC2N 6LE    51.509413   -0.121676
3   WC2N 6NA    51.508363   -0.124454
4   WC2N 6ND    51.508216   -0.123829

虽然这是在 geopandas 中读取的形状文件

borough = gpd.read_file('London_Borough_Excluding_MHW.shp')
borough.head()
borough.head()

NAME    GSS_CODE    geometry
0   Kingston upon Thames    E09000021   POLYGON ((516401.6 160201.8, 516407.3 160210.5...
1   Croydon E09000008   POLYGON ((535009.2 159504.7, 535005.5 159502, ...
2   Bromley E09000006   POLYGON ((540373.6 157530.4, 540361.2 157551.9...
3   Hounslow    E09000018   POLYGON ((521975.8 178100, 521967.7 178096.8, ...
4   Ealing  E09000009   POLYGON ((510253.5 182881.6, 510249.9 182886, ...

我们可以看到多边形的坐标与 post代码的坐标有何不同。我和当我把它们放在一起时我得到

fig, ax = plt.subplots()
borough.plot(ax = ax)
borough = gpd.read_file('statistical-gis-boundaries-london/ESRI/London_Borough_Excluding_MHW.shp')
london_post_codes.plot(kind='scatter',s=10, x='longitude', y='latitude',ax=ax)

有什么建议吗?

解决办法就是简单地更改CRS(Coordinate Reference System). These go by codes, which are called EPSG. The WSG84 lat/long CRS的EPSG代码为4326。因此

borough = gpd.read_file('London_Borough_Excluding_MHW.shp')
borough = borough.to_crs(epsg=4326)

然后剩下的。