我有一个来自http://www.nyc.gov/html/exit-page.html?url=https://s3.amazonaws.com/nyc-tlc/misc/taxi_zones.zip的shapefile。每个区域都有多边形文件(边界),我获得了每个区域的质心。我需要质心,以便可以将它们绘制在Gephi上并用于网络分析。我的问题是,Gephi要求坐标为经度(-74.001648,40.724243),但我获得的质心为UTM(例如935996.821,191376.7495)。如何在Python中将UTM转换为经/纬度?我尝试了这段代码,但是返回了一个奇怪的纬度:
import pyproj as pp
from mpl_toolkits.basemap import Basemap
import pandas as pd
zones = list(range(1,264))
x = []
y = []
for z in zones:
x.append(ny_map[ny_map['OBJECTID'] == z].geometry.centroid.x.values[0])
y.append(ny_map[ny_map['OBJECTID'] == z].geometry.centroid.y.values[0])
ny_map['x'] = pd.Series(x)
ny_map['y'] = pd.Series(y)
#32618 is the code for NY as per my Google search but not sure
utm18_wgs84 = pp.Proj(init='epsg:32618')
ny_map[['lat', 'long']] = ny_map.apply(lambda row:utm18_wgs84(row['x'], row['y'], inverse=True), axis=1).apply(pd.Series)