资源简介
使用Python编写的坐标投影转换,需要输入的是源数据的EPSG代号和目标数据的EPSG代号,具体说明文档见文件夹内
![](http://www.nz998.com/pic/38445.jpg)
代码片段和文件信息
# -*- encoding: utf-8 -*-
import urlliburllib2
import requests
import json
import os
def convert(xys_srst_srs):
url=‘http://epsg.io/trans‘
textmod ={‘x‘:x‘y‘:y‘s_srs‘:s_srs‘t_srs‘:t_srs}
textmod = urllib.urlencode(textmod)
print(textmod)
#输出内容:password=admin&user=admin
req = urllib2.Request(url = ‘%s%s%s‘ % (url‘?‘textmod))
print(req.get_full_url())
res = urllib2.urlopen(req)
res = res.read()
print(res)
def request(datas_srst_srs):
url=‘http://epsg.io/trans‘
textmod ={‘data‘:data‘s_srs‘:s_srs‘t_srs‘:t_srs}
response = requests.get(url params=textmod)
jsonData = response.json()
coor=json.dumps(jsonData)
return coor
# print(json)
# 遍历指定目录,显示目录下的所有文件名
def eachFile(filepath):
pathDir = os.listdir(filepath)
for allDir in pathDir:
child = os.path.join(‘%s%s‘ % (filepath allDir))
childPath=child.decode(‘gbk‘) # .decode(‘gbk‘)是解决中文显示乱码问题
with open(childPath ‘r‘) as file:
json_data = file.read()
json_data = json.loads(json_data)
s_srs=json_data[‘s_srs‘]
t_srs=json_data[‘t_srs‘]
cdata=json_data[‘data‘]
coor=request(cdatas_srst_srs)
outPutPath=os.path.splitext(childPath)[0]+‘Convert.txt‘
with open(outPutPath ‘w‘) as wfile:
geojson=json.dumps(coor)
geojson.replace(‘u\‘‘‘\‘‘)
geojson=geojson.decode(“unicode-escape“)
wfile.write(geojson)
print(‘success‘)
def readFile():
path=os.path.dirname(os.path.realpath(__file__))#获取py文件所在文件夹
txtDirPath=path+‘\\txt\\‘
eachFile(txtDirPath)
def reptile():
url=‘http://epsg.io/trans?y=2544675&x=36518161&t_srs=4326&s_srs=2360‘
page = urllib.urlopen(url)
return page.read()
if __name__==‘__main__‘:
# request(36518161254467523604326)
readFile()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-14 16:03 根据epsg代号进行坐标批量转换\ConvertByEpsg\
文件 2056 2018-08-22 15:55 根据epsg代号进行坐标批量转换\ConvertByEpsg\convert.py
目录 0 2018-11-14 16:03 根据epsg代号进行坐标批量转换\ConvertByEpsg\txt\
文件 69 2018-08-22 15:45 根据epsg代号进行坐标批量转换\ConvertByEpsg\txt\demoData.txt
文件 143 2018-08-22 15:59 根据epsg代号进行坐标批量转换\ConvertByEpsg\说明.txt
- 上一篇:基于python的图书管理系统
- 下一篇:基于PCA的故障检测Python代码
相关资源
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
- 量化交易(附python常见函数的使用方
- python 名字用字排行
评论
共有 条评论