python实现坐标点的系统转换
生活随笔
收集整理的這篇文章主要介紹了
python实现坐标点的系统转换
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
python實現坐標點的系統轉換
arcgis本來就不怎么會,加上好長時間沒有使用,居然忘了怎么導點轉坐標了,沒辦法,正好看到這篇文章,可以用python實現坐標系統的轉換。查找了相關內容,編了一小段,可以快速實現坐標轉換,十分完美!主要參見了知乎上的這篇文章。
#coding:utf-8import os import numpy as np from pyproj import CRS from pyproj import Transformerfrom_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: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轉的結果的對比:
總結
以上是生活随笔為你收集整理的python实现坐标点的系统转换的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数据通信系统的模型
- 下一篇: LeetCode#17 Python解