Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My question is similar to the Cell Statistics gives Wrong Answer question. In Python, I'm using the MINIMUM parameter to execute the cell statistics tool on several reclassified rasters ('0's and '1's) and I'm not getting accurate results. However, when I use the tool in ArcMap I get what I'm looking for. It seems as if it's only using two rasters (don't know which ones). Here's the code I'm using.

arcpy.env.workspace = ("F:\\hdf\\hdf_test\\reclass")
outh10v03 = ("F:\\hdf\\hdf_test\\h10v03\\")

h10v03 = arcpy.ListRasters("*2000*h10v03*", "tif")

for reclass in h10v03:
    print reclass

arcpy.gp.CellStatistics_sa(h10v03, outh10v03 + "h10v03_2000" + ".tif", "MINIMUM", "DATA")

Any ideas as to why it's not using all rasters (I believe that's the case)?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I'm not certain if the problem is due to indentation in your code, or whether it is due to formatting on the site:

for reclass in h10v03:
    print reclass

arcpy.gp.CellStatistics_sa(reclass, outh10v03 + "h10v03_2000" + ".tif", "MINIMUM", "DATA") 
# only the last line is run once

In this case it should loop through all of the tifs in the folder:

for reclass in h10v03:
    print reclass    
    arcpy.gp.CellStatistics_sa(reclass, outh10v03 + "h10v03_2000" + ".tif", "MINIMUM", "DATA")
    # here the line arcpy.gp.CellStatistics_sa ... is run for every raster in h10v03
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com?utm_source=stackoverflow.com&amp;utm_medium=site-ui&amp;utm_campaign=footerlink\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a>                   with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.10.25.1965\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Geographic Information Systems Stack Exchange works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt="], "copyright__copyright__copyright": ["it should loop through all of the tifs in the folder:\n\nfor reclass in h10v03:\n    print reclass    \n    arcpy.gp.CellStatistics_sa(reclass, outh10v03 + \"h10v03_2000\" + \".tif\", \"MINIMUM\", \"DATA\")\n    # here the line arcpy.gp.CellStatistics_sa ... is run for every raster in h10v03\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}