Matplotlib 在Python中将lon/lat转换为tmerc

Matplotlib 在Python中将lon/lat转换为tmerc,matplotlib,geopandas,Matplotlib,Geopandas,我有和的shp文件(stops.txt文件) 城市边界呈流动投影 gdf.crs {'proj': 'tmerc', 'lat_0': 0, 'lon_0': 18, 'k': 0.999923, 'x_0': 6500000, 'y_0': 0, 'ellps': 'GRS80', 'units': 'm', 'no_defs': True} 而公共汽车站坐标为普通lon lat格式 如何使用python更改投影并将其绘制在同一图表上 编辑: 当我尝试执行to_crs方法时

我有和的shp文件(stops.txt文件)

城市边界呈流动投影

gdf.crs

{'proj': 'tmerc',
 'lat_0': 0,
 'lon_0': 18,
 'k': 0.999923,
 'x_0': 6500000,
 'y_0': 0,
 'ellps': 'GRS80',
 'units': 'm',
 'no_defs': True}
而公共汽车站坐标为普通lon lat格式

如何使用python更改投影并将其绘制在同一图表上

编辑: 当我尝试执行
to_crs
方法时

gdf1 = gdf1.to_crs("EPSG:4326")

我得到一个错误:

Traceback (most recent call last):

  File "<ipython-input-11-a2ef4c434a50>", line 1, in <module>
    gdf1 = gdf1.to_crs("EPSG:4326")

  File "D:\Anaconda_Python\lib\site-packages\geopandas\geodataframe.py", line 545, in to_crs
    geom = df.geometry.to_crs(crs=crs, epsg=epsg)

  File "D:\Anaconda_Python\lib\site-packages\geopandas\geoseries.py", line 424, in to_crs
    proj_out = pyproj.Proj(crs, preserve_units=True)

  File "D:\Anaconda_Python\lib\site-packages\pyproj\__init__.py", line 362, in __new__
    return _proj.Proj.__new__(self, projstring)

  File "_proj.pyx", line 129, in _proj.Proj.__cinit__

RuntimeError: b'no arguments in initialization list'
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
gdf1=gdf1.至crs(“EPSG:4326”)
文件“D:\Anaconda\u Python\lib\site packages\geopandas\geodataframe.py”,第545行,在to crs中
geom=df.几何体至crs(crs=crs,epsg=epsg)
文件“D:\Anaconda\u Python\lib\site packages\geopandas\geoseries.py”,第424行,在to crs中
项目输出=pyproj.proj(crs,保存单位=True)
文件“D:\Anaconda\u Python\lib\site packages\pyproj\\uuuuu init\uuuuuu.py”,第362行,在新的__
返回项目项目新项目(self,projstring)
文件“_proj.pyx”,第129行,在项目中__
运行时错误:b'初始化列表中没有参数'

谢谢。不幸的是,我在尝试运行“to_crs”方法时出错。有关详细信息,请参见编辑。我使用Spyder IDE不确定您使用的是什么gpd和cartopy版本,但我的第一个解决方案分别适用于0.7.0和0.17.0。我刚刚在版本为0.4.1和0.17.0的机器上测试了gdf1=gdf1.to_crs({'init':'epsg:4326'})语法,它在我的机器上运行。如果可以,我建议更新gpd。
Traceback (most recent call last):

  File "<ipython-input-11-a2ef4c434a50>", line 1, in <module>
    gdf1 = gdf1.to_crs("EPSG:4326")

  File "D:\Anaconda_Python\lib\site-packages\geopandas\geodataframe.py", line 545, in to_crs
    geom = df.geometry.to_crs(crs=crs, epsg=epsg)

  File "D:\Anaconda_Python\lib\site-packages\geopandas\geoseries.py", line 424, in to_crs
    proj_out = pyproj.Proj(crs, preserve_units=True)

  File "D:\Anaconda_Python\lib\site-packages\pyproj\__init__.py", line 362, in __new__
    return _proj.Proj.__new__(self, projstring)

  File "_proj.pyx", line 129, in _proj.Proj.__cinit__

RuntimeError: b'no arguments in initialization list'
import cartopy
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import geopandas as gpd
import pandas as pd


gdf1 = gpd.read_file('GraniceOsiedli.shp')

gdf1 = gdf1.to_crs("EPSG:4326")
#gdf1.to_crs({'init': 'epsg:4326'}) for older versions of gpd

df = pd.read_csv('stops.txt')

proj = ccrs.PlateCarree(central_longitude=0)

fig, ax = plt.subplots(subplot_kw=dict(projection=proj), figsize=(16,16))
ax.set_extent([df['stop_lon'].min()-0.01,
               df['stop_lon'].max()+ 0.01,
               df['stop_lat'].min()- 0.01,
               df['stop_lat'].max()+0.01], 
              crs=ccrs.PlateCarree())

fig.canvas.draw()
fig.tight_layout()

ax.scatter(df['stop_lon'].values.tolist(), df['stop_lat'].values.tolist())
ax.add_geometries(gdf1['geometry'], crs=proj, facecolor="none", edgecolor="red")

plt.show()