Python-UTM坐标与经纬度(WGS84)坐标转换
source link: http://www.banbeichadexiaojiubei.com/index.php/2021/01/09/python-utm坐标与经纬度wgs84坐标转换/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
pyproj是一个非常好用的地图投影和坐标转换库。
pip install pyproj
构造Transformer
from pyproj import Transformer transformer = Transformer.from_crs(4326, 32651) transformer = Transformer.from_crs("EPSG:4326", "EPSG:32651")
CRS(Coordinate Reference System)用于指定转换的源坐标系和目标坐标系。4326、32650是坐标系的唯一编号(WKID,Well Known ID),4326对应的就是WGS84地理坐标系统,32650对应WGS_1984_UTM_Zone_51N。
如果对自己需要进行转换的坐标系的WKID不了解,可以从以下两个网站进行查询:
地理坐标系WKID: https://developers.arcgis.com/javascript/3/jshelp/gcs.htm
投影坐标系WKID: https://developers.arcgis.com/javascript/3/jshelp/pcs.htm
实现坐标变换
utm_x, utm_y = transformer.transform(30.90786255,121.84786891) print("utm_x:{}, utm_y:{}".format(utm_x, utm_y))
完整的转换代码如下:
from pyproj import Transformer transformer = Transformer.from_crs(4326, 32651) transformer = Transformer.from_crs("EPSG:4326", "EPSG:32651") utm_x, utm_y = transformer.transform(30.90786255,121.84786891) print("utm_x:{}, utm_y:{}".format(utm_x, utm_y))
输出的转换结果如下:
utm_x:389901.44142316026, utm_y:3419959.5095140757
在线坐标转换
如果不想写代码,或者只是小批量的坐标转换,可以直接在线转换。在线转换地址:https://www.earthpoint.us/Convert.aspx
https://www.earthpoint.us/Convert.aspx参考材料
https://github.com/pyproj4/pyproj
https://pyproj4.github.io/pyproj/stable/examples.html
除非注明,否则均为[半杯茶的小酒杯]原创文章,转载必须以链接形式标明本文链接
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK