应用python读取IGS站
大概思路
1.从pyecharts(数据可视化)的库中,导入Geo (地理坐标系组件)用于地图的绘制,map 函数 地图主要用于(地理区域数据)的可视化。
from pyecharts import Geo,Map
难点:需要对库的模块进行安装
2.根据已有的资料,读取csv文件。将其中的内容标题进行索引,根据用户自主选择内容来进行查询。
难点:①根据自己所需要的目录进行提取;②如何根据用户的需求来进行选取
# _*_ coding: utf-8 _*_
# @Author : 师太丶借ge吻
# @Time : 2019/6/2414:57
# @File : new_igs_station_v2.0.py.py
# @Software: PyCharm"""1.将程序放入到函数中2.根据客户的更多需求来满足,输入序号后输入格式错误3.没有实现汉英之间的相互转换4.按照地区来进行划分5.创建成函数6.做成循环的,可以随时退出7.想查单个的(①找出所有的可能性,全部列出,可能性太多了②将填写的做成列表或字典,进行对比)
"""import csv # 导入模块csv
import json # 导入模块json
import re
from pyecharts import Geo,Map # 从pyecharts库中,导入Geo和Map模块files_dictionary = {} # 创建一个空的文件字典
attitude_datas = [] # 创建一个总的海拔数据的空列表
coordinate_datas = {} # 创建一个总的坐标数据的空字典"""打开文件,挑选出自己需要的数据"""
number = 0 # 起算数据
filename = 'IGS_CSV.csv'
with open(filename) as fp: # 打开文件,并将结果文件对象存储在fp中reader = csv.reader(fp) # 调用csv.reader(),并将存储的文件对象作为实参传递给它,创建一个与该文件相关联的阅读器attitude_data = () # 创建一个海拔数据元祖for x in reader: # for循环遍历该文件if number == 0: # 当起算数据为0时heard_row = x # 表头else: # 当起算数据不为0时site_information = {} # 需要的位置信息创建一个空字典site_information[heard_row[0]] = x[0]site_information[heard_row[1]] = x[1]site_information[heard_row[4]] = x[4]site_information[heard_row[5]] = x[5]site_information[heard_row[8]] = x[8]site_information[heard_row[9]] = x[9]site_information[heard_row[10]] = x[10]site_information[heard_row[20]] = x[20]files_dictionary[number] = site_information # 有序号的位置信息加入到空的总数据字典site_altitude = (x[0],) + (x[10],) # 海拔信息attitude_datas.append(site_altitude) # 将海拔信息添加到空的总海拔列表lat_long = list((x[9],) + (x[8],)) # 坐标信息coordinate_datas[x[0]] = lat_long # 将坐标信息添加到空的总坐标列表number += 1print(files_dictionary)
print(attitude_datas)
print(coordinate_datas)for i,v in enumerate(site_information,1): # for循环按照序号顺序遍历字典中的信息print(i,'>>>>',v)
header = list(site_information) # 提取字典的标题,组成新的列表while True:choice = input('请您输入序号(退出:q):')if choice.isdigit():choice = int(choice)if choice > 0 and choice <= len(header)-1:choice_finish = header[choice - 1] # 选择的序号,与标题对应提取出来information = input('%s:'%choice_finish)# 将客户的输入进行大小写划分if choice_finish == 'City' or choice_finish == 'Country':information = information.title()else:information = information.upper()# 想查单个的(①将输入的提取到列表中;②列表中是否含有)elif choice == len(header):sat_system_choice_new_result = []sat_system_list = ['GPS','GLO','GAL','BDS','QZSS','SBAS','IRNSS','WAAS']for num,ber in enumerate(sat_system_list,1):print(num,'-->',ber)sat_system_choices = input('请输入您想选择的系统编号(多系统用加号连接,退出输入q):')if sat_system_choices != 'q':sat_system_choices = re.sub("\D", "", sat_system_choices) # 提取字符串中的数字for sat_system_choice in sat_system_choices:sat_system_choice_result = sat_system_list[int(sat_system_choice) - 1]sat_system_choice_new_result.append(sat_system_choice_result)#选择出了想要测量的系统sat_system_results = "+".join(sat_system_choice_new_result)information = sat_system_resultselse:print('对不起,您输入的序号有误!')break# 怎样把选择出来的字典给提取出来site_coordinate = {}choice_attitude_datas = []choice_coordinate_datas = {}for keys,values in files_dictionary.items(): # for循环遍历总文件字典中的键-值for key,value in values.items(): # for循环遍历总文件字典中的值的键-值print(value)print(information)if information in value: # if判断条件final_choice = files_dictionary[keys]choice_coordinate_datas[final_choice['Site']] = coordinate_datas[final_choice['Site']]choice_attitude_datas.append(attitude_datas[keys - 1])print(choice_attitude_datas)print(choice_coordinate_datas)elif choice == 'q':print('您已退出!')break# 把数据保存成json格式
filename = 'choice_datas.json'
with open(filename,'w') as f_obj:json.dump(choice_coordinate_datas,f_obj)def map_drawing():""""根据用户选出的数据来进行绘图"""geo = Geo("全球IGS观测站分布", "data from www.igs.org", title_color="#fff",title_pos="center", width=1000,height=600,background_color='#404a59')attr, value = geo.cast(choice_attitude_datas)geo.add_coordinate_json("choice_datas.json")geo.add("", attr, value, visual_range=[0, 4000], maptype='world', visual_text_color="#fff",symbol_size=6, is_visualmap=True)geo.render("全球IGS观测站分布.html")
应用python读取IGS站相关推荐
- python删除重复值所在的行数_使用python读取txt文件的内容,并删除重复的行数方法...
注意,本文代码是使用在txt文档上,同时txt文档中的内容每一行代表的是图片的名字. #coding:utf-8 import shutil readDir = "原文件绝对路经" ...
- python 爬虫抓站
python 爬虫抓站 记录(虾米,百度,豆瓣,新浪微博) python 下用到的库,urllib, urllib2, BeautifulSoup, cookielib, mechanize, re ...
- Python读取文件内容为字符串的方法(多种方法详解)
方法1: 拷贝文章时,直接把内容赋值给一个变量,保存到一个 .py 文件中.然后在脚本中,导入它. 存储文章的文件article.py content = """ 复制的 ...
- python读取csv某一列存入数组_python 读取.csv文件数据到数组(矩阵)的实例讲解
利用numpy库 (缺点:有缺失值就无法读取) 读: import numpy my_matrix = numpy.loadtxt(open("1.csv","rb&qu ...
- python读取图片的格式_python读取图片并修改格式与大小的方法
本文实例为大家分享了python读取图片并修改文件大小的具体代码,供大家参考,具体内容如下 # Author:NDK # -*- coding:utf-8 -*- from PIL import Im ...
- python读取word内容复制粘贴,Python读取word文本操作详解
本文研究的主要问题时Python读取word文本操作,分享了相关概念和实现代码,具体如下. 一,docx模块 Python可以利用python-docx模块处理word文档,处理方式是面向对象的.也就 ...
- 使用python爬虫抓站的一些技巧总结:进阶篇 (转)
本文出处:http://obmem.info/?p=753 Posted on November 23, 2010 by observer 以前写过一篇使用python爬虫抓站的一些技巧总结,总结了诸 ...
- 使用Python读取LabVIEW TDMS 格式文件转成Excel格式+多进程版本
使用Python读取LabVIEW TDMS 格式文件转成Excel格式+多进程版本 文章目录 使用Python读取LabVIEW TDMS 格式文件转成Excel格式+多进程版本 前言: 背景 tm ...
- python获取键盘输入_python之判断数据异常Python读取键盘输入
Python提供了两个内置函数从标准输入读入一行文本,默认的标准输入是键盘.如下: <python之判断数据异常Python读取键盘输入>总结了关于python网站教程,对于我们来www. ...
最新文章
- C语言可以不用,但是不能不会!
- 26.使用ajaxSetup()方法设置全局Ajax默认选项
- php %3cphp用大括号表示,整理HTML5中支持的URL编码与字符编码_html5教程技巧
- Android开发之修改项目的仓库地址亲测有效
- Android 如何让EditText不自动获取焦点
- java登陆密码验证失败,java用户名密码验证示例代码分享
- 使用JavaScript将图片保存至本地
- 西门子1200走总线FB284控制3台V90伺服和相机调整角 度,DP通讯控制FANUC机器人
- 超变单职业传奇脱机辅助制作视频教程
- 计算机一级是几寸的,14寸笔记本电脑分辨率多少合适?14寸笔记本电脑尺寸是多少?...
- 无线路由器实现网络接入
- Exercise39: python字典(访问,操作,list(), dirt.items(), dirt.get() )
- 代理服务器和IP加速器之间有什么关系?
- 【洛谷】P1359 租用游艇
- .Art域名注册局的行为其实早就引起了众多域名界大佬的强烈不满
- vanishing point detection in autopilot
- Rosalind第七题:孟德尔第一定律
- Python 之正则表达re.compile()与re.findall()详解
- phpcms 之 添加栏目时,输入英文栏目之后,总是提示栏目已存在
- 加拿大魁北克大学计算机,加拿大魁北克大学.pdf