# -*- 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图片的更多相关文章

  1. python读取数据库并把数据写入本地文件

    一,介绍 上周用jmeter做性能测试时,接口B传入的参数需要依赖接口A生成的借贷申请ID,接口A运行完需要把生成的借贷申请ID导出来到一个文件,作为参数传给接口B,刚开始的时候,手动去数据库倒, 倒 ...

  2. python读取grib grib2气象数据

    如何读取GRIB数据?快看Python大神整理的干货! 橙子心法 百家号17-11-0116:30 GRIB是WMO开发的一种用于交换和存储规则分布数据的二进制文件格式,主要用来表示数值天气预报的产品 ...

  3. 两分钟解决Python读取matlab的.mat数据

    Matlab是学术界非常受欢迎的科学计算平台,matlab提供强大的数据计算以及仿真功能.在Matlab中数据集通常保存为.mat格式.那么如果我们想要在Python中加载.mat数据应该怎么办呢?所 ...

  4. Python读取字典(Dictionary)内数据的方法

    读取json后,数据类型为字典,对字典内数据的提取又有不同的方法,根据不同的字典类型 上图可以看到有”[]”,”{}” python语言最常见的括号有三种,分别是:小括号( ).中括号[ ]和大括号也 ...

  5. Python读取excel表的数据

    from openpyxl.reader.excel import load_workbook #读取xlsx文件def readExcelFile(path): dic={} #打开文件 file= ...

  6. python 读取单所有json数据写入mongodb(单个)

    <--------------主函数-------------------> from pymongo import MongoClientfrom bson.objectid impor ...

  7. Python读取Excel中的数据并导入到MySQL

    """ 功能:将Excel数据导入到MySQL数据库 """ import xlrd import MySQLdb # Open the w ...

  8. python读取.mat文件的数据

    首先导入scipy的包 from scipy.io import loadmat 然后读取 m = loadmat("F:/__identity/activity/论文/data/D001. ...

  9. Python 读取word中表格数据、读取word修改并保存、替换word中词汇、读取word中每段内容,读取一段话中相同样式内容,理解Document中run

    from docx import Document path = r'D:\pywork\12' # word信息表所在文件夹 w = Document(path + '/' + 'word信息表.d ...

随机推荐

  1. Ubuntu 安装软件

    1,安装pthread的man文档 sudo apt-get install manpages-posix manpages-posix-dev

  2. Metro中控件WebView访问外部的网页显示一片空白

    Metro中控件WebView访问外部的网页显示一片空白 解决方案: ​下载安装了Initex.Software.Proxifier.v3.21.Standard.Edition.Incl.Keyma ...

  3. Swift vs. Objective-C:未来看好 Swift 的十个理由

    Swift vs. Objective-C:未来看好 Swift 的十个理由 是时候使用易入手又全面的Swif语言为iOS和mac OS X做应用开发了. 虽然编程语言不会那么容易消逝,但坚持衰落范例 ...

  4. Power-BI 关于2016年7月份深圳一手房房价分析报表 腾讯课堂开课啦

         上周我们的公开课讲了全国房地产投资开发的情况,通过对时间.区域等多维度的分析,透析了全国房地产开发的投资情况.这周呢,我们就全国一线城市的房价,选取了深圳作为分析对象,对深圳一手房房价进行一 ...

  5. makefile中引用其他makefile方法

    在Makefile中引用其他Makefile文件的方法是,使用inclue   filename.mk

  6. Visual Studio Debugger AutoExp.dat & Visualization Framework

    bing.com搜索: autoexp.dat 参考资料: AutoExp.dat http://www.virtualdub.org/blog/pivot/entry.php?id=120 http ...

  7. 给ubuntu系统换新装

    此次安装主要按照Flatabulous:Ubuntu系统美化主题 但自己在安装过程中发现了很多问题,一下一段黑色的是上面链接的文章,红色的是自己在操作过程中的一些改动 安装主题的第一步是安装Ubunt ...

  8. DIY小能手|别买电动滑板车了,咱做一台吧

    !! http://www.shoudian.org/thread-316111-1-1.html http://www.jiequer.com/html/news/xinpin/2014/1218/ ...

  9. [转]Apache Maven 入门篇(下)

    原文地址: Apache Maven 入门篇(下) 作者:George Ma 第一篇文章大概的介绍了一下Apache Maven以及它的下载和安装,并且运行了一个简单的示例.那么在对maven有了一点 ...

  10. SQL2008无法连接到.\SQLEXPRESS,用户'sa'登录失败(错误18456)图文解决方法

      出现问题 :标题: 连接到服务器 ------------------------------ 无法连接到 .\SQLEXPRESS. ------------------------------ ...