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 ...
随机推荐
- Python模块 (psutil)
psutil psutil是Python中一个系统信息检索模块,可以获取(系统.CPU.内存.网络.磁盘)等信息,可以应用于系统的监控.健康状态检查,等同于shell中的ps.free.top.df功 ...
- [RGEOS]支持栅格数据读取和显示
SharpMap真的很强大,这里通过改造GdalRasterLayer类实现了在RGeos项目中支持栅格图像的读取和显示,同时支持影像的无级缩放. GdalRasterLayer通过读取FWTools ...
- 用仿ActionScript的语法来编写html5——第九篇,仿URLLoader读取文件
第九篇,仿URLLoader读取文件 先看看最后的代码 function readFile(){ urlloader = new LURLLoader(); urlloader.addEventLis ...
- javascript设计模式学习之十三——职责链模式
一.职责链的定义和使用场景 职责链模式的定义是,职责链模式将一系列可能会处理请求的对象连接成一条链,请求在这些对象之间一次传递,直到遇到一个可以处理它的对象.从而避免请求的发送者和接收者之间的耦合关系 ...
- 使用NSURLSession请求需要AD认证的HTTPS服务器
关键代码:使用后台下载PDF文件 - (void)startDownloadPDF{ NSURLSession *session = [self session]; NSString *downloa ...
- Function.prototype.bind接口浅析
本文大部分内容翻译自 MDN内容, 翻译内容经过自己的理解. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Glo ...
- redmine一键安装
参加项目 bitnami项目 https://bitnami.com/stack/redmine/installer 百度网盘地址为:http://pan.baidu.com/s/1jESnO
- C# web api 返回类型设置为json的两种方法
每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...
- 文字排版一律用plist
NSMutableArray *newhealthArr = [NSMutableArray new]; NSArray *healthTitleArr = [NSArray arrayWithCon ...
- php实用类
<?php class DBDA { public $host="localhost";//服务器地址 public $uid="root";//用户名 ...