你好哇,@#¥。
你要是愿意,我就永远爱你。你要是不愿意,我就永远相思。
我把我整个灵魂都给你,连同它的怪癖,耍小脾气,忽明忽暗,一千八百种坏毛病。它真讨厌,只有一点好,爱你。
不管我本人多么平庸,我总觉得对你的爱很美。
告诉你,一想到你,我这张丑脸上就泛起微笑。还有在我安静的时候,你就从我内心深处浮现,就好像阿芙罗蒂从浪花里浮现一样。
我和你就像两个小孩子,围着一个神秘的果酱罐,一点一点地尝它,看看里面有多少甜。
要无忧无虑地去抒情,去歌舞狂欢,去向世界发出我们的声音,我一个人是不敢的,我怕人家说我疯。有了你我就敢。只要有你一个,就不孤独!
我的勇气和你的勇气加起来,对付这个世界足够了吧!
你是非常可爱的人,真应该遇到最好的人,我也真希望我就是。
当我跨过沉沦的一切,向着永恒开战的时候,你是我的军旗。
你想知道我对你的爱情是什么吗?就是从心底里喜欢你,觉得你的一举一动都很亲切,不高兴你比喜欢我更喜欢别人。
你要是喜欢了别人我会哭,但是还是喜欢你。你肯用这样的爱情回报我吗?就是你高兴我也高兴,你难过时我来安慰你,还有别爱别人!
咱们应当在一起,否则就太伤天害理啦。
我现在不坏了,我有了良心。我的良心就是你。
祝你今天愉快,你明天的愉快留着我明天再祝。
思路:
1-(ArcGIS)change magnitude
2-(ENVI roi)find change area
3-(ArcGIS buffer)extract
4-(raster calculator)循环搜索
以下代码为第4部分循环搜索:
# -*- coding: utf-8 -*-
'''input:
changearea.shp, A
nochangearea.shp
magnitude.tif, max, min
nstep, nstep_d
sigma
'''
import arcpy
smallwidow_path = "E:/work/6_ArcGIS_python/data2use/all25.shp" # 内窗口,即典型变化区域
bigwindow_path = "E:/work/6_ArcGIS_python/data2use/erasearea.shp" # 外窗口,即非变化区域,用内窗口使用buffer结合erase得到
changemagni_path = "E:/work/6_ArcGIS_python/data2use/magnitude.tif"
changemagni_max = 14733.725585938
changemagni_min = 0
A = 1982
nstep = 10
nstep_q = 5 # 每次变步长时对nstep的变化, nstep *= nstep_q
sigma = 0.001 # 退出while循环的阈值
def getpixelnum(fc):
'''输入setnull得到的变化tif,得到变化像元的数量'''
rows = arcpy.SearchCursor(fc)
for row in rows:
pixelnumber = row.getValue("Count")
return pixelnumber
arcpy.env.workspace = "E:/work/6_ArcGIS_python/5_output_py" # 工作路径,用于存储输出结果
maxthre = changemagni_max # 每次变步长搜索的阈值区间 = maxthre - minthre
minthre = changemagni_min
Lmax = 1 # 退出while循环的条件
Lmin = 0
step = (changemagni_max - changemagni_min) / nstep # 变化的nstep得到变化的step
L = {} # 存储检验成功率L
Threshold = {}
x = 0
ftxt = open("record.txt", "w")
while (Lmax - Lmin > sigma):
# threshold_list = range(minthre, maxthre, step) #此处可考虑是否将maxthre算在内
threshold_list = [(minthre + step * k) for k in range(11)]
Threshold[str(x)] = threshold_list
L[str(x)] = [0 for k in range(len(threshold_list))]
j = 0
for threshold in threshold_list:
# use threshold to get change area
expression = "SetNull('" + changemagni_path + "' < " + str(threshold) + ', 1)' # 'SetNull("magnitude.tif" < 2000, 1)'
filename = str(x) + '_threshold_' + str(threshold) + ".tif"
threshold_output = arcpy.env.workspace + '/magnithreshold/' + filename # "E:/work/6_ArcGIS_python/calculsetnull2000.tif"
arcpy.gp.RasterCalculator_sa(expression, threshold_output)
# extract threshold change tif to get small's and big window's change tif
smallmask_output = arcpy.env.workspace + '/mask/' + str(x) + '_window_1_' + str(threshold) + ".tif" # "E:/work/6_ArcGIS_python/calculsetnull2000_extractchange.tif"
bigmask_output = arcpy.env.workspace + '/mask/' + str(x) + '_window_2_' + str(threshold) + ".tif"
arcpy.gp.ExtractByMask_sa(threshold_output, smallwidow_path, smallmask_output)
arcpy.gp.ExtractByMask_sa(threshold_output, bigwindow_path, bigmask_output)
# calculate the accuracy L
pixelnum_smallwindow = getpixelnum(smallmask_output)
pixelnum_bigwindow = getpixelnum(bigmask_output)
L[str(x)][j] = (pixelnum_smallwindow - pixelnum_bigwindow) / A
j += 1
ftxt.write(str(x) + "\n" + str(Threshold[str(x)]) + "\n" + str(L[str(x)]) + "\n") #每次迭代输出阈值list和精度list
# update threshold interval and step for loops
Lmax = max(L[str(x)])
Lmin = min(L[str(x)])
maxthre = threshold_list[L[str(x)].index(max(L[str(x)]))] + step
minthre = threshold_list[L[str(x)].index(max(L[str(x)]))] - step
nstep = nstep * nstep_q # update n
step = (changemagni_max - changemagni_min) / nstep
x += 1
ftxt.write("Threshold, Accuracy\n")
ftxt.write(str(Threshold[str(len(Threshold) - 1)][L[str(len(L) - 1)].index(max(L[str(len(L) - 1)]))]) + "," + str(max(L[str(len(L) - 1)]))) #输出最后的精度及对应的阈值
ftxt.close()
代码不是直接复制到arcgis的python就能运行,需要更改输入文件和输出文件的路径,否则会出错