|
POST
|
Hi All, BY the help of below script, i trying to get properties of raster using mask file. I want certain area statistics value of raster. So far i have, but its getting error while performing the task import arcpy
arcpy.env.workspace = r"D:\Annomaly_SPEI_12"
arcpy.env.Mask = r"D:\Agro_Zone\Zone-1.shp"
Mask = arcpy.env.Mask
rasterList = arcpy.ListRasters()
for raster in rasterList:
rasterObj = arcpy.Raster(raster)
print raster
bands = arcpy.GetRasterProperties_management(Mask ,raster, "MEAN")
print "MEAN VALUE: %s" %bands
Error Massage : ERROR 000864: Property type: The input is not within the defined domain.
ERROR 000800: The value is not a member of MAXIMUM | MINIMUM | MEAN | STD | TOP | LEFT | RIGHT | BOTTOM | CELLSIZEX | CELLSIZEY | VALUETYPE | COLUMNCOUNT | ROWCOUNT | BANDCOUNT | ALLNODATA | ANYNODATA | SENSORNAME | PRODUCTNAME | ACQUSITIONDATE | SOURCETYPE | CLOUDCOVER | SUNAZIMUTH | SUNELEVATION | SENSORAZIMUTH | SENSORELEVATION | OFFNADIR | WAVELENGTH.
ERROR 000864: Band Name: The input is not within the defined domain.
ERROR 000800: The value is not a member of Band_1.
Failed to execute (GetRasterProperties).
... View more
03-31-2017
05:47 AM
|
0
|
9
|
3578
|
|
POST
|
xander_bakker, Thank you very much. Now its working fine.
... View more
03-30-2017
10:39 PM
|
0
|
5
|
1555
|
|
POST
|
Xander Bakker, Thanks for your respond. I have attached the datasets to thread.
... View more
03-29-2017
06:26 AM
|
0
|
7
|
1555
|
|
POST
|
192 views , still received input from 3 -4 developer only.
... View more
03-29-2017
04:58 AM
|
0
|
9
|
1555
|
|
POST
|
xander_bakker, please cooperate with us to solve the issue.
... View more
03-29-2017
01:40 AM
|
0
|
3
|
1555
|
|
POST
|
Patterson i have updated the line 16-19, still script behave the same for Rasters in rasterList:
rasMean = arcpy.sa.CellStatistics(Rasters,"MEAN", "DATA")
file_name_only = os.path.splitext(Rasters)[0]
tifname = file_name_only[-4:]
... View more
03-29-2017
01:06 AM
|
0
|
4
|
2465
|
|
POST
|
Hi, I have updated my script, Below script printing only folder name, its not calculating the mean of raster from different folder Script: import arcpy, os
from arcpy import env
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True
env.workspace = r"D:\Test"
outraster = env.workspace
walk = arcpy.da.Walk(env.workspace, topdown=True, datatype="RasterDataset")
for dirpath, dirnames, filenames in walk:
print dirpath
rasterList = []
for file in filenames:
raster = os.path.join(dirpath, file)
rasterList = arcpy.ListRasters("TIF")
for Rasters in rasterList:
rasMean = arcpy.sa.CellStatistics(Rasters,"MEAN", "DATA")
file_name_only = os.path.splitext(Rasters)[0]
tifname = file_name_only[-4:]
rasMean.save(os.path.join(outraster,'Mean_{0}.tif'.format(tifname)))
print rasMean After running the script, its printing folder only D:\Test
D:\Test\2001
D:\Test\2002
D:\Test\2003
D:\Test\2004
D:\Test\2005
D:\Test\2006
D:\Test\2007
D:\Test\2008
D:\Test\2009
... View more
03-28-2017
11:58 PM
|
0
|
0
|
2465
|
|
POST
|
@lan , i heve updated above code, but its producing only single output name "mean" and overlapping the output for multiple time in main folder, output not save in source of input raster folder
... View more
03-25-2017
03:30 AM
|
0
|
4
|
2465
|
|
POST
|
i added the line,but its behave the same as earlier . arcpy.CheckOutExtension("Spatial")
... View more
03-24-2017
12:48 PM
|
0
|
0
|
2465
|
|
POST
|
Hi All, I am writing a script to loop through multiple folders and calculate mean of the raster of each folder's data sets and save it in same folder. Below script i am working, but its not producing the mean rasters for each year folder, after running the script its generating only name of "mean" raster in main folder, and overlapping it . Below images showing the name of the raster in one folder, another folder the raster name is same, only year value is changed in different year. here how to take the year value in name of mean raster (E.g. for 2001 folder, output mean raster name would be Mean_Temp_2001.tif, E.g. for 2002 folder, output mean raster name would be Mean_Temp_2002.tif) Below i have attached data sets also (Test_data folder)v which i am working on. Thanks. import arcpy, os
from arcpy import env
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True
env.workspace = r"D:\Test"
outraster = env.workspace
walk = arcpy.da.Walk(env.workspace, topdown=True, datatype="RasterDataset")
for dirpath, dirnames, filenames in walk:
print dirpath
rasterList = []
for file in filenames:
raster = os.path.join(dirpath, file)
rasterList.append(raster)
rasMean = arcpy.sa.CellStatistics(rasterList,"MEAN")
rasMean.save(os.path.join(outraster,"mean.tif"))
print rasMean
... View more
03-24-2017
12:18 PM
|
0
|
23
|
6504
|
|
POST
|
Dan Patterson, Thank you. I just solved the issue, using below command if int(nowFile[-4:]) == 2002: Thank you all for your kind cooperation.
... View more
03-23-2017
11:48 AM
|
1
|
1
|
883
|
|
POST
|
Dan Patterson sorry for late response. I was out of station. Here i tried to follow your suggestion. after assign the year (2002), its create only one raster not extracting all month data in 2002. dimension_values = nc_FP.getDimensionValue(dimension, i)
nowFile = str(dimension_values)
nowFile = nowFile.translate(None, '/')
nowFile = ('2002')
# I needed only the years 2002
if int(nowFile[:-2]):
... View more
03-23-2017
10:36 AM
|
0
|
0
|
883
|
|
POST
|
Dan Patterson, @Joshus, I have made some changes in the script, rather than using CSV for extracting particular time period, i am using below script to extract desired time period raster from NetCDF, here line no 14 controlling the time period, if int(nowFile[-2]) > 6 In above line > 6 is extracting the all year data after 1988, when i increase the value by 1 then extracting year also sifting by1 year (e.g. If i put 7 then it would be extract all the year of 1989). But i want to make a condition for extracting the specific year, e.g1985 to 1990, i don't want pre and post data of that year. Any assist would be greatly appreciated. Thanks nc_FP = arcpy.NetCDFFileProperties(inNetCDF)
print nc_FP
nc_Dim = nc_FP.getDimensions()
for dimension in nc_Dim:
if dimension == "time":
top = nc_FP.getDimensionSize(dimension)
for i in range(0, top):
dimension_values = nc_FP.getDimensionValue(dimension, i)
nowFile = str(dimension_values)
nowFile = nowFile.translate(None, '/')
# I needed only the years 1990, post 1990 data i don't want
if int(nowFile[-2]) > 8:
dv1 = ["time", dimension_values]
dimension_values = [dv1]
arcpy.MakeNetCDFRasterLayer_md(inNetCDF, variable, x_dimension, y_dimension, nowFile, band_dimension, dimension_values, valueSelectionMethod)
print "success"
outname = outLoc + nowFile
arcpy.CopyRaster_management(nowFile, outname + ".tif", "", "", "", "NONE", "NONE", "")
else: print "Enter a Valid year"
... View more
03-12-2017
12:32 PM
|
0
|
4
|
3097
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-01-2017 09:56 PM | |
| 1 | 01-19-2017 08:03 AM | |
| 1 | 07-31-2017 11:57 AM | |
| 1 | 08-25-2016 09:38 AM | |
| 1 | 08-17-2016 11:13 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:25 AM
|