python 读取全国城市aqi数据,差值生成png图片
# -*- coding: utf-8 -*-
import arcpy
import sys
import datetime
import cx_Oracle
import json
import os
import time
import uuid
from arcpy import env
from arcpy.sa import * env.workspace = r"F:\py";
mapPath = r"F:\py";
imagepath = r'F:\py\images\2016-06-07' arcpy.AddMessage("1.查询数据库");
cnxn = cx_Oracle.connect('jinan/jinan@127.0.0.1:1521/orcl')
cursor = cnxn.cursor();
sql = "select citycode,aqi from city ";
cursor.execute(sql);
cursorData = cursor ; arcpy.AddMessage("2.数据保存到fc");
for item in cursorData:
print item[0]+'-'+item[1]; fc = "F:\py\jinan.gdb/city";
where = "CITYCODE=" +item[0];
rows = arcpy.UpdateCursor(fc,where);
for row in rows:
row.setValue('aqi1',item[1]);
rows.updateRow(row)
del rows ,fc; arcpy.AddMessage("3.进行差值操作");
inPointFeatures = "F:\py\jinan.gdb/city";
inBarrierFeature = "F:\py\jinan.gdb/barrier";
cellSize = 10000.0
arcpy.CheckOutExtension("Spatial")
outSplineBarriers = SplineWithBarriers(inPointFeatures, 'aqi1', inBarrierFeature, cellSize, 1);
tif = "pointraster.tif";
tif1 = "pointraster1.tif";
outSplineBarriers.save(tif); arcpy.AddMessage("4.根据行政区边界图层剪切栅格")
outExtractByMask = ExtractByMask(tif, inBarrierFeature)
outExtractByMask.save(tif1) arcpy.AddMessage("5.更新mxd");
mxdPath = mapPath + r"\pointraster1.mxd";
mxd = arcpy.mapping.MapDocument(mxdPath);
df = arcpy.mapping.ListDataFrames(mxd, "")[0];
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
arcpy.mapping.RemoveLayer(df, lyr);
addLayer = arcpy.mapping.Layer(mapPath + r"\pointraster1.lyr")
arcpy.mapping.AddLayer(df, addLayer, "BOTTOM") arcpy.AddMessage("6.输出图片png");
fileName ="aqi.png"
df.extent = addLayer.getSelectedExtent()
arcpy.mapping.ExportToPNG(mxd, imagepath+"\\" + fileName , df, background_color="255,255,255", transparent_color="255,255,255",world_file=True); arcpy.AddMessage("7.清理内存")
del mxd, addLayer,df,outSplineBarriers,inPointFeatures,inBarrierFeature
python 读取全国城市aqi数据,差值生成png图片的更多相关文章
- python读取数据库并把数据写入本地文件
一,介绍 上周用jmeter做性能测试时,接口B传入的参数需要依赖接口A生成的借贷申请ID,接口A运行完需要把生成的借贷申请ID导出来到一个文件,作为参数传给接口B,刚开始的时候,手动去数据库倒, 倒 ...
- python读取grib grib2气象数据
如何读取GRIB数据?快看Python大神整理的干货! 橙子心法 百家号17-11-0116:30 GRIB是WMO开发的一种用于交换和存储规则分布数据的二进制文件格式,主要用来表示数值天气预报的产品 ...
- 两分钟解决Python读取matlab的.mat数据
Matlab是学术界非常受欢迎的科学计算平台,matlab提供强大的数据计算以及仿真功能.在Matlab中数据集通常保存为.mat格式.那么如果我们想要在Python中加载.mat数据应该怎么办呢?所 ...
- Python读取字典(Dictionary)内数据的方法
读取json后,数据类型为字典,对字典内数据的提取又有不同的方法,根据不同的字典类型 上图可以看到有”[]”,”{}” python语言最常见的括号有三种,分别是:小括号( ).中括号[ ]和大括号也 ...
- Python读取excel表的数据
from openpyxl.reader.excel import load_workbook #读取xlsx文件def readExcelFile(path): dic={} #打开文件 file= ...
- python 读取单所有json数据写入mongodb(单个)
<--------------主函数-------------------> from pymongo import MongoClientfrom bson.objectid impor ...
- Python读取Excel中的数据并导入到MySQL
""" 功能:将Excel数据导入到MySQL数据库 """ import xlrd import MySQLdb # Open the w ...
- python读取.mat文件的数据
首先导入scipy的包 from scipy.io import loadmat 然后读取 m = loadmat("F:/__identity/activity/论文/data/D001. ...
- Python 读取word中表格数据、读取word修改并保存、替换word中词汇、读取word中每段内容,读取一段话中相同样式内容,理解Document中run
from docx import Document path = r'D:\pywork\12' # word信息表所在文件夹 w = Document(path + '/' + 'word信息表.d ...
随机推荐
- 用NPOI操作EXCEL关于HSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2)的参数
2.4.1 用NPOI操作EXCEL关于HSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2)的参数 NPOI教程:http://www.cnb ...
- MVC4 数据验证、特性、自动属性总结
最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来. 十年河东十年河西,莫欺少年穷 学无止境,精益求精 最近在做自学MVC,遇到的问题很多,索性一点点总结 ...
- C# SQL优化 及 Linq 分页
每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...
- snapshot standby database
快照备库接收和归档主库发送来的redo,但是不会应用:切换成physical standby之后会自动开启redo apply.快照standby不可以参加主备切换:在最大保护性模式下,如果只有一个备 ...
- runcluvfy.sh运行结果
$ ./runcluvfy.sh stage -pre crsinst -n rac11g1,rac11g2 -verbose Performing pre-checks for cluster se ...
- EBS运行快速安装的程序时,提示DISPLAY变量设置不对
EBS运行快速安装的程序时,系统提示如下: Rapid Install Wizard is validating your file system...... >> Wizard requ ...
- Starting MySQL...The server quit without updating PID file
修改mysql的配置文件(my.cnf)后,再启动mysqld的时候报错: # service mysqld start Starting MySQL...The server quit withou ...
- Tomcat学习 HttpConnector和HttpProcessor启动流程和线程交互
一.tomat启动流程 1.启动HttpConnector connector等待连接请求,只负责接受socket请求,具体处理过程交给HttpProcessor处理. tomcat用户只能访问到co ...
- spring 小结
第一步:配置 web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xs ...
- IDEA文件编码修改
上图标注 1 所示,IDE 的编码默认是 UTF-8,Project Encoding 虽然默认是 GBK,但是一般我都建议修改为 UTF-8.上图标注 2 所示,IntelliJ IDEA 可以对 ...