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 ...
随机推荐
- free 命令
free命令可以显示Linux系统中空闲的.已用的物理内存及swap内存,及被内核使用的buffer.在Linux系统监控的工具中,free命令是最经常使用的命令之一. 1.命令格式: free [参 ...
- iptables常用操作
1.iptables服务重启 service iptables restart 2.保存iptables规则 iptables-save > ~/iptables.save 3.恢复iptabl ...
- BCP及自增标识列
10:58 2012-12-20 通过BCP命令导入导出数据 bcp "test.dbo.lxy133" out d:\lxy133.txt -SMSSQL$SQL08R2 -Us ...
- category分类
/* 使用继承关系来扩充一个类,有一个弊病,高耦合性 category(分类,类别) 能够帮我们扩充一个类的功能 */ - (void)superJump { // [self eat]; [s ...
- [Linux Tips] 1. 查看端口
查看监听的端口 # netstat -lnp
- 详解 ASP.NET并行,异步,多线程
最近在学习.net4以上版本新特性的时候,发现在异步这方面提供了很多好玩的.以下Mark 2篇好文,温故而知新! http://www.cnblogs.com/wisdomqq/archive/201 ...
- 对jsp可见域的变量感悟
page 变量当前页面有效 reqeust 某次请求中的变量有效 session 某次会话中的变量有效 application 全站有效 page<request<session< ...
- Ios(ipad iphone) 支持字体一览
Font Name : ThonburiFont Name : Snell RoundhandFont Name : Academy Engraved LETFont Name : AvenirFon ...
- html 标签内部元素左右居中
<div style="width: 500px; height: 500px; border: 1px solid red; text-align: center;"> ...
- java List 简单使用
Student类 class Student{ String name; String pwd; public Student(){} public Student(String name, Stri ...