python獲取柵格點(diǎn)和面值的實(shí)現(xiàn)
1、獲取指定位置的點(diǎn)值:
OutputFile = open(statisticResultTXT, ’w’) cellvalue=arcpy.GetCellValue_management(inputfilepath+filenname+'.tif',staionXY, '1')OutputFile.write(stationID+'_'+filenname+''+str(cellvalue)+’n’)OutputFile.close()
2、獲取區(qū)域的均值極值
utputFile = open(statisticResult, ’w’) env.workspace = (’E:loessplateauET_Splineextract_year’)rlist = arcpy.ListRasters(’*’,’tif’)for file in rlist: minValueInfo= arcpy.GetRasterProperties_management(file,’MINIMUM’)minValue = minValueInfo.getOutput(0)maxValueInfo = arcpy.GetRasterProperties_management(file,’MAXIMUM’)maxValue = maxValueInfo.getOutput(0)meanValueInfo = arcpy.GetRasterProperties_management(file,’MEAN’)meanValue = meanValueInfo.getOutput(0)print file + ’,’ + str(minValue) + ’,’ + str(maxValue) + ’,’ + str(meanValue) +’n’OutputFile.write(file + ’,’ + str(minValue) + ’,’ + str(maxValue) + ’,’ + str(meanValue) +’n’)OutputFile.close()
補(bǔ)充知識(shí):python_計(jì)算格點(diǎn)數(shù)據(jù)降水變化斜率
我就廢話不多說了,還是直接看代碼吧!
import numpy as npimport pandas as pdimport codecs path=r’C:try.csv’ #讀取格點(diǎn)數(shù)據(jù)CSVdata=pd.read_csv(path,encoding=’gbk’)outpath=r’C:rate.csv’#新建存放斜率的CSVfile_csv = codecs.open(outpath,’w+’,’utf-8’) #打開方式data1=data.T #轉(zhuǎn)置n=80 #格點(diǎn)數(shù)m=17 #年數(shù)sl=[] #空列表for i in list(range(0,80)):#循環(huán)計(jì)算80個(gè)格點(diǎn)的變化斜率 print (i) sp=[] y=data1[i] y=y.values for k in range(0,m-1): for j in range(k+1,m): print(k,j) s=(y[j]-y[k])/(j-k) #計(jì)算斜率 sp.append(s) sl.append(np.median(sp)) slop= pd.DataFrame(sl)slop.to_csv(outpath,header=[’slop’]) #將SLOP寫入CSV
以上這篇python獲取柵格點(diǎn)和面值的實(shí)現(xiàn)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Spring security 自定義過濾器實(shí)現(xiàn)Json參數(shù)傳遞并兼容表單參數(shù)(實(shí)例代碼)2. Java8內(nèi)存模型PermGen Metaspace實(shí)例解析3. python tkinter實(shí)現(xiàn)下載進(jìn)度條及抖音視頻去水印原理4. ASP.NET MVC使用正則表達(dá)式驗(yàn)證手機(jī)號(hào)碼5. 一文搞懂 parseInt()函數(shù)異常行為6. Python 有可能刪除 GIL 嗎?7. Python使用sftp實(shí)現(xiàn)上傳和下載功能8. python捕獲警告的三種方法9. python 統(tǒng)計(jì)list中各個(gè)元素出現(xiàn)的次數(shù)的幾種方法10. Python基于百度AI實(shí)現(xiàn)抓取表情包
