GeoPandas .to_crs()方法未转换 [英] GeoPandas .to_crs() method not converting

查看:80
本文介绍了GeoPandas .to_crs()方法未转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些数据集转换为相同的坐标系(NC2264)

I am trying to convert some datasets into the same coordinate system (NC2264)

NC2264 = 'EPSG:2264'

sfd_subs = pd.read_csv(r'FILE_LOCATION.csv')
wake_shapes = gpd.GeoDataFrame.from_file(r'FILE_LOCATION.shp').to_crs(NC2264)

sfd_subs = gpd.GeoDataFrame(sfd_subs, geometry=gpd.points_from_xy(sfd_subs.Longitude, sfd_subs.Latitude),crs='EPSG:4326')
sfd_subs.to_crs(NC2264)

print(sfd_subs.crs)

shapefile转换可以正常工作,但是'sfd_subs'保持不变.我没有任何错误.

The shapefile conversion works perfectly but the 'sfd_subs' remains unchanged. I'm getting no errors.

我在顶部包含了5个正确的转化,而在底部则包含了不变的转化.

I've included 5 of the correct conversions on top vs the unchanged conversion on the bottom.

EPSG:4326
0       POINT (2641914.208 1398556.771)
1       POINT (2642559.277 1398183.388)
2       POINT (2641705.300 1398352.924)
3       POINT (2641716.844 1397826.942)
4       POINT (2674989.747 1419749.281)
                     ...               
3332             POINT (-78.135 35.506)
3333             POINT (-78.130 35.504)
3334             POINT (-78.123 35.530)
3335             POINT (-78.104 35.537)
3336             POINT (-78.087 35.562)

由于我没有收到任何错误,所以我不确定最好的做法是什么.

Since I'm getting no errors I'm not sure what the best course of action is.

推荐答案

您必须将转换后的GeoDataFrame分配给变量,因为该函数不会就地对其进行修改.

You have to assign a converted GeoDataFrame to a variable, as the function doesn't modify it inplace.

# instead of only writing: sdf_subs.to_crs(NC2264), assign it back to variable
sdf_subs = sfd_subs.to_crs(NC2264)

这篇关于GeoPandas .to_crs()方法未转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆