python实现坐标点的系统转换
arcgis本来就不怎么会,加上好长时间没有使用,居然忘了怎么导点转坐标了,没办法,正好看到这篇文章,可以用python实现坐标系统的转换。查找了相关内容,编了一小段,可以快速实现坐标转换,十分完美!主要参见了知乎上的这篇文章。
#coding:utf-8
import os
import numpy as np
from pyproj import CRS
from pyproj import Transformer
from_crs = CRS.from_epsg(4326) #坐标系统从下面这个网址查询
to_crs = CRS.from_epsg(32649) #https://developers.arcgis.com/javascript/3/jshelp/pcs.htm
input_file = "./point.txt"
output_file = "./output.txt"
transformer = Transformer.from_crs(from_crs,to_crs,always_xy=True)
with open(output_file,"w") as fo:
with open(input_file,"r") as fi:
while True:
line = fi.readline() # 逐行读取
array=line.split()
if not line:
break
else:
data = [ float(x) for x in array[1:] ]
print(data)
lon = data[0]
lat = data[1]
x,y = transformer.transform(lon,lat)
fo.write("\t".join(["{}".format(array[0]),"{:.6f}".format(x),"{:.6f}".format(y),'\n']))
print('All Done')
这是与arcgis转的结果的对比: