python实现坐标点的系统转换

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转的结果的对比:
结果的对比

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值