python实现坐标点的系统转换
生活随笔
收集整理的這篇文章主要介紹了
python实现坐标点的系统转换
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
python實現(xiàn)坐標(biāo)點的系統(tǒng)轉(zhuǎn)換
arcgis本來就不怎么會,加上好長時間沒有使用,居然忘了怎么導(dǎo)點轉(zhuǎn)坐標(biāo)了,沒辦法,正好看到這篇文章,可以用python實現(xiàn)坐標(biāo)系統(tǒng)的轉(zhuǎn)換。查找了相關(guān)內(nèi)容,編了一小段,可以快速實現(xiàn)坐標(biāo)轉(zhuǎn)換,十分完美!主要參見了知乎上的這篇文章。
#coding:utf-8import os import numpy as np from pyproj import CRS from pyproj import Transformerfrom_crs = CRS.from_epsg(4326) #坐標(biāo)系統(tǒng)從下面這個網(wǎng)址查詢 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:breakelse: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轉(zhuǎn)的結(jié)果的對比:
總結(jié)
以上是生活随笔為你收集整理的python实现坐标点的系统转换的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数据通信系统的模型
- 下一篇: web安全与字体——刘尧博士讲座--PD