2

I have a lot of MODIS tif files in a folder and I want to calculate zonal statistics of each tiff file according to polygon in my shapefile. I am trying this in ModelBuilder of ArcMap 10.3.1 Model Builder in Arcmap 10.3.1

However, It's giving me this error: Error

I google alot and find inline variable name in zonal statistics throwing me error by using %name%. I google for solution and some posts suggest me to use collect value and parse path. I am using ArcMap 10.3.1 not find parse path function and also not able to apply correctly collect value.

How can I find zonal statistics of bluck of tif files according to my shapefile in ArcMap?

This processing should be automatic to reduce my time.

Editing 1 After Suggestions on this Question:

After Suggestions of Parse Path

Getting this Error: enter image description here

Will you please help How to use Parse Path Tool. I've given parse tool output as precondition to Zonal statistics and the above error was come. How can I remove this please?

Editing No 2:

Editing 2 is done in 3 steps: Step 1: Using raster iterator I am accessing Correct_ET folder till 2002001.tif (Green circle) and description of iterator is given in the picture below:Raster Iterator

Step 2: In this step I'm using Parse tool and giving green cirle (2002001.tif) as input and selecting name in Parse tool as shown in picture below: Complete information of Parse Path tool

Step 3: final, I am giving 2002001.tif as input raster and District as shapefile which has attribute District_n (Admin polygon) and Setting output path of table in seperate folder EET with %name% as shown below:Zonal Statistics Complete information

the Output (Value circle) is given as precondition input to zonal statistics however, the errors remains the same? All this complete information is model share in editing 1 of this question

8
  • If you wish to also ask about doing this in QGIS then please do that in a separate question.
    – PolyGeo
    Commented Jan 6, 2022 at 21:48
  • 1
    Can you expose the tool parameters used in the model for "Zonal Statistics" GP ops? Commented Jan 7, 2022 at 6:47
  • I have all Modis Rasters in a folder named Corrected_ET and through raster iterator in model builder i am reading this folder. According to iteration, its reading first Modis raster in Corrected_ET folder which has name 20002001.tif then after that I am reading my shapefile which contains 36 admin boundary polygon under attribute district_N and then I am setting *mean of raster under these admin polygon. While saving the Zonal statistics I'm setting path of new folder and giving my zonal statistics table for each raster as %name%. However, this giving me an error? @Yogi Commented Jan 7, 2022 at 15:49
  • Please edit your question by including a screen shot of how you are setting the zonal stats as table tool, so a screen shot of the tool open and completed as you are doing.
    – Hornbydd
    Commented Jan 8, 2022 at 15:42
  • 1
    You are not following my instructions and using the wrong inline substitution. You are still using %name% as the table output. You need to be using the output of Parse path which is %value%. And if you read my original answer I end it with .dbf. so you need to set the output name to %value%.dbf
    – Hornbydd
    Commented Jan 9, 2022 at 1:35

1 Answer 1

4

Firstly rename the output of the iterator to something like "Raster" rather than 2002001.tif, just makes things clearer to understand.

Using %Name% as your inline variable substitution is taking the name of the raster from the iterator (the light blue bubble) which would of course be something like "2002001.tif". I'm guessing in the zonal stats tool your output table parameter is set to something like J:\..filepath...\%Name%

Well the substitution would create a table name ending with .tif which would be invalid as @BERA indicates in the comments. You need to rebuild the table name to something like 2002001.dbf.

dbf is a valid table name extension name. Your output table would be in a dBase format.

Use Parse Path tool to return the name part and lets assume its output is called NewName. Parse Path tool needs to be a precondition to the zonal stats tool. So finally in the zonal stats tool your output table parameter would something like J:\..filepath...\%NewName%.dbf

6
  • Dear, you understand my problem well. Yeah 2002001.tif is the first raster in the folder of Correct_ET. Yeah, you also right in output I am creating zonal statistics.dbf.tiff which is not a valid format. Yeah, you are right sir as well I need to use Parse Path tool but I am using Arcmap 10.3.1 version and I find alot this tool in this version. Is this tool is available in this version? As you told, I have to used parse path as precondition to zonal statistics. Whether its input be my 2002001.tif? Will you please provide me solution in flow chart dear? @Hornbydd Commented Jan 7, 2022 at 15:59
  • will you please tell me how and where I have to use parse path. I try parse path as precondition to zonal statistics and also tried all its parse type but an error was coming which I post above in my editing to the question? A flow chart to by urside will be highly appreciated? Commented Jan 7, 2022 at 16:49
  • 1
    @MuhammadUsmanSaleem your updated model screenshot is correct but you have not set up the Parse Path tool correct, Read the help file. You have accepted the default parse type of FILE you need to be using NAME to return only 2002001 portion of 2002001.tif
    – Hornbydd
    Commented Jan 7, 2022 at 16:56
  • No dear, the error remains the same even If I use file name in parse path and given the value of this parse path as environment-> Output config keyword or as precondition to zonal statistics tool. Testing both case giving me error ERROR 000622: Failed to execute (ZonalStatisticsAsTable). Parameters are not valid. and ERROR 000883: Output table: .tif's extension is invalid for the output table. Model giving these two errors and model is continuous working in output with these two errors @Hornbydd? guide me dear Commented Jan 8, 2022 at 7:13
  • I think, when I used file name in parse path and value of parse path as precondition to the zonal statisitcs its just reading 2002001 file as input. while this tool need raster file. My problem is in setting the name of output if I used %name% in output of Zonal Stat, its carry tif extension from the input raster. Is there way I force my output of zonal statistics to remove extension from input and save the statistics .dbf with 2002001 only? Commented Jan 8, 2022 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.