在Geopandas中转换shapefile的坐标

在Geopandas中转换shapefile的坐标

本文介绍了在Geopandas中转换shapefile的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是空间分析的新手,但我找不到任何答案.

I am new at spatial analysis, but I cant find this answer anywhere.

我有一个用CRS坐标,纬度和经度表示的邮政编码列表,以及一个用OSN坐标表示的伦敦自治市镇形状文件的列表,我想将它们映射在一起,但这是发生的情况.这是邮政编码的头

I have a list of post codes in CRS coordinates, latitude and longitude, and London's Boroughs shape file in OSN coordinates, and I would like to map them together, but this is what happens. This is the head of the 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

这是在大熊猫中读取的形状文件

while this is the shape file read in 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, ...

我们可以看到多边形的坐标与邮政编码的坐标有何不同.我,当我将它们绘制在一起时,我得到了

we can see how the coordinates of the polygons are different from those of the postcodes. I and when I plot them together I get

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(坐标参考系统).这些按代码命名,称为 EPSG . WSG84 lat/long CRS的EPSG代码为4326.因此

The solution is simply to change the CRS (Coordinate Reference System). These go by codes, which are called EPSG. The WSG84 lat/long CRS has a EPSG code of 4326. Therefore

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

,然后其余的.

这篇关于在Geopandas中转换shapefile的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 02:19