# -*- 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. 背景建模SACON

    http://www.cnblogs.com/dwdxdy/p/3530862.html

  2. 一个前端html模板处理引擎(javascript) - pure

    做后台开发(java/python)的同学开发web应用,对于前端页面生成技术并不陌生,像jsp,freemark等.开发UGC类型的互联网站,因为要SEO友好,所以一般都会在后台用模板引擎直接生成好 ...

  3. iOS - (几个 button 按钮之间的单选与多选)

    先来看看效果图: 下面是实现的代码: 首先创建10个button(一个一个写太麻烦了,个人认为还是用一个 for 循环来创建比较好) 下面就是 button 的点击方法实现单选 多选的比较好做,写法也 ...

  4. iOS如何统计渠道

    http://bbs.umeng.com/thread-10-1-1.html https://www.zhihu.com/question/20697933

  5. 获取git的最后一次提交的commit id

    git log --pretty=format:"%h" | head -1  | awk '{print $1}' 可以放到xcode  build setting  post ...

  6. 运行sql server profiler所需的权限

    ********运行Sql Server Profiler所需的权限(performance)*********/ --EG. -- 使用TRACE帐户(Performancetest)跟踪Sql S ...

  7. ie8 不支持new Date('2012-11-10')

    ie 不支持Date.now()以及Date的一些方法开始是在火狐上使用new Date(Date.now())的的方法,这个写法也很sb,当然了当时也没想太多,比较我不是做前台的Date.now() ...

  8. nyist 626 intersection set

    http://acm.nyist.net/JudgeOnline/problem.php?pid=626 intersection set 时间限制:1000 ms  |  内存限制:65535 KB ...

  9. 怎样解决MySQL数据库主从复制延迟的问题---流行网站的解决办法(转载)

    像Facebook.开心001.人人网.优酷.豆瓣.淘宝等高流量.高并发的网站,单点数据库很难支撑得住,WEB2.0类型的网站中使用MySQL的 居多,要么用MySQL自带的MySQL NDB Clu ...

  10. 自定义Scrollview--实现仿淘宝Toolbar透明度渐变效果

    ,上个月做了下电商的项目,本来以为本简单的,但做起来还是遇到了不少的问题,上个周五项目就上线了,不过时间还是很紧,PM给了我两天时间总结总结,然后又要开始一个新的项目和这个项目的迭代,感觉又要开始累死 ...