<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script Zonal statistics: runtime error - cannot open file in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271008#M20961</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;mmm, I see what might be going wrong. You are using a raster with floating values. The script uses a search cursor on the attribute table of the raster (see line 82). Since the raster is float, it does not have an attribute table (hence the error).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this part of the thread it is explained that the code requires an integer raster &lt;A href="https://community.esri.com/message/391136"&gt;Re: Zonal statistics - percentiles&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the precision is not too exact want you require, you could convert the raster to integer and try again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Jul 2015 18:13:54 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2015-07-06T18:13:54Z</dc:date>
    <item>
      <title>Script Zonal statistics: runtime error - cannot open file</title>
      <link>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271004#M20957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm running a script that it's basically zonal statistic over polylines (I modified one script that I found in this forum &lt;A href="https://community.esri.com/thread/95403"&gt;Zonal statistics - percentiles&lt;/A&gt; ).&lt;/P&gt;&lt;P&gt;The code takes a shape file containing the lines along which I want to analyse the elevation. For every line, it creates a raster (let's say it converts the line into a raster) where in every pixel it writes the corresponding elevation value. It analyses the values of the elevation along the line and returns the max, min and percentiles values. It repeats the same thing for all the lines in the shape file.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The code is running without problems with a certain digital elevation model. Recently I received a new LiDAR file and I tried to run the code but I got an error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RuntimeError: cannot open "line1.tif"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;line1.tif is the line converted to raster. I checked the file and it is exactly the line in tif format with the right values of elevation. The folder in which it is stored, is the same as using the previous DEM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The DEM and LiDAR have different resolution and therefore line1.tif in case of DEM in something like 2 KB and in case of LIDAR around 60 KB. This is the only difference I can notice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone has a clue of what is happening?&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fabio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 14:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271004#M20957</guid>
      <dc:creator>FabioCian</dc:creator>
      <dc:date>2015-07-06T14:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script Zonal statistics: runtime error - cannot open file</title>
      <link>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271005#M20958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;​ this one is yours&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 15:27:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271005#M20958</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-07-06T15:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script Zonal statistics: runtime error - cannot open file</title>
      <link>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271006#M20959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dan, I will try and see if this one can be resolved...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi, &lt;A href="https://community.esri.com/migrated-users/138095"&gt;Fabio Cian&lt;/A&gt; , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you make any other changes to the code and if so, could you include the code in this thread? (see: &lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;​) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as I can deduce from the original code I wrote, it uses polygons to extract the percentiles. To do that, it will create a list of points and use that in the &lt;EM&gt;ExtractByPolygon&lt;/EM&gt; tool to extract the cells inside the polygon. If your geometry is a straight line it probably will create an invalid polygon. If the line has a curve, it will probably include much more than you want in your data. To avoid this, I suppose you could create a a buffer around the lines (using the cellsize as buffer width) and use those polygons in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to attach the line1.tif to this thread to have a look of what you are working with, or include a screen shot of the data?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 15:59:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271006#M20959</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-07-06T15:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script Zonal statistics: runtime error - cannot open file</title>
      <link>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271007#M20960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, thanks a lot for replying.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached the file (named ras1.tif instead of line1.tif). This is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def GetPixelValueForPercentile(dctper, percentile):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; """will return last pixel value 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where percentile LE searched percentile."""&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; pix_val = sorted(dctper.keys())[0] # initially assign lowest pixel value&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for k in sorted(dctper.keys()):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perc = dctper&lt;K&gt;&amp;nbsp; &lt;/K&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if perc &amp;lt;= percentile:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pix_val = k&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return pix_val&amp;nbsp; 
&amp;nbsp; 
def FieldExist(featureclass, fieldname):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Check if field exists"""&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList = arcpy.ListFields(featureclass, fieldname)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return len(fieldList) == 1&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp; 
import arcpy, sys
from arcpy import env
from arcpy.sa import *
env.workspace = r"C:\Users\Flood Depth"


f = open('log_file.txt', 'w')


# Enable Spatial analyst&amp;nbsp; 
arcpy.CheckOutExtension("Spatial")


# settings&amp;nbsp; 
ras = r"C:\Users\Dataset\Flood_Depth\LiD_MA_Sal_cm.tif"&amp;nbsp; 
fc = r"C:\Users\Dataset\Flood_Depth\C_Saletto.shp"&amp;nbsp; 
# ras = r"C:\Path\To\Folder\Or\Geodatabase\With\Raster"&amp;nbsp; 
# fc = r"C:\Path\To\Folder\Or\Geodatabase\With\PolygonFeatureclass"&amp;nbsp; 
lst_perc = [2, 5, 10, 90, 95, 98] # list of percentiles to be calculated&amp;nbsp; 
fld_prefix = "Perc_"&amp;nbsp; 
f.write("DEM File input: " + ras + "\n")
f.write("Shapefile input: " + fc + "\n" + "\n")
&amp;nbsp; 
# arcpy.env.workspace = "IN_MEMORY"&amp;nbsp; 
arcpy.env.overwriteOutput = True&amp;nbsp; 
&amp;nbsp; 
# add fields if they do not exist in fc&amp;nbsp; 
# be aware, field that exist will be overwritten!&amp;nbsp; 
print "filling field list and adding fields"&amp;nbsp; 
flds = []&amp;nbsp; 
for perc in lst_perc:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; fld_perc = "{0}{1}".format(fld_prefix, perc)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; flds.append(fld_perc)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not FieldExist(fc, fld_perc):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(fc, fld_perc, "LONG")&amp;nbsp; 
print "flds={0}".format(flds)&amp;nbsp; 
&amp;nbsp; 
# loop through polygons&amp;nbsp; 
print "loop through polygons"&amp;nbsp; 
flds.append("SHAPE@")&amp;nbsp; 
i = 0&amp;nbsp; 
with arcpy.da.UpdateCursor(fc, flds) as curs:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 1&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Processing polygon: {0}".format(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write("Processing polygon: {0}".format(i) + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = row[flds.index("SHAPE@")]


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Execute ExtractByMask (you can't send the polygon object)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - ExtractByMask..."&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ras_pol = ExtractByMask(ras, polygon)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outname = "ras{0}".format(i) + ".tif"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ras_pol.save(outname)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - saved raster as {0}".format(outname)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2) #"Unexpected error:", sys.exc_info()[0]
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create dictionary with value vs count&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - fill dict with Value x Count"&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flds_ras = ("VALUE", "COUNT")&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dct = {row[0]:row[1] for row in arcpy.da.SearchCursor(outname, flds_ras)}&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # calculate number of pixels in raster&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - determine sum"&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt_sum = sum(dct.values())&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - sum={0}".format(cnt_sum)&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # loop through dictionary and create new dictionary with val vs percentile&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - create percentile dict"&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_per = {}&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt_i = 0&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for val in sorted(dct.keys()):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt_i += dct[val]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_per[val] = float(cnt_i) / float(cnt_sum)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sort_dct_per = sorted(dct_per)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print sort_dct_per
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print dct_per
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # loop through list of percentiles&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - iterate perceniles"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(" - iterate perceniles" + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for perc in lst_perc:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # use dct_per to determine percentiles&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perc_dec = float(perc) / 100&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "&amp;nbsp;&amp;nbsp; - Perc_dec for is {0}".format(perc_dec)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write("&amp;nbsp;&amp;nbsp; - Perc_dec for is {0}".format(perc_dec) + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pixval =&amp;nbsp; GetPixelValueForPercentile(dct_per, perc_dec)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "&amp;nbsp;&amp;nbsp; - Perc for {0}% is {1}".format(perc, pixval)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write("&amp;nbsp;&amp;nbsp; - Perc for {0}% is {1}".format(perc, pixval)+ "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # write pixel value to percentile field&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "&amp;nbsp;&amp;nbsp; - Store value"&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fld_perc = "{0}{1}".format(fld_prefix, perc)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[flds.index(fld_perc)] = pixval&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # update row&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print " - update row"&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curs.updateRow(row)


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del(outname)
&amp;nbsp; 
# return SA license&amp;nbsp; 
arcpy.CheckInExtension("Spatial")&amp;nbsp; 
f.close()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:15:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271007#M20960</guid>
      <dc:creator>FabioCian</dc:creator>
      <dc:date>2021-12-11T13:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script Zonal statistics: runtime error - cannot open file</title>
      <link>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271008#M20961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;mmm, I see what might be going wrong. You are using a raster with floating values. The script uses a search cursor on the attribute table of the raster (see line 82). Since the raster is float, it does not have an attribute table (hence the error).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this part of the thread it is explained that the code requires an integer raster &lt;A href="https://community.esri.com/message/391136"&gt;Re: Zonal statistics - percentiles&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the precision is not too exact want you require, you could convert the raster to integer and try again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 18:13:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271008#M20961</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-07-06T18:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script Zonal statistics: runtime error - cannot open file</title>
      <link>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271009#M20962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot! That was the problem!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fabio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 08:47:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271009#M20962</guid>
      <dc:creator>FabioCian</dc:creator>
      <dc:date>2015-07-07T08:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script Zonal statistics: runtime error - cannot open file</title>
      <link>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271010#M20963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad it solved your problem...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 20:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-zonal-statistics-runtime-error-cannot-open/m-p/271010#M20963</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-07-07T20:38:29Z</dc:date>
    </item>
  </channel>
</rss>

