<?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: Spatial Analyst - calculate median raster values within polygons in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49555#M663</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;The experts can correct me if I'm wrong, but another approach is to use Z&lt;/SPAN&gt;&lt;STRONG&gt;onal Statistics as Table&lt;/STRONG&gt;&lt;SPAN&gt;. This creates a table with all the stats in it. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Process:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;Run &lt;/SPAN&gt;&lt;STRONG style="line-height: 1.5;"&gt;Zonal Statistics as Table&lt;/STRONG&gt;&lt;SPAN style="line-height: 1.5;"&gt; choosing a unique field in the polygon shapefile (FID works).&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;the table with the statistics is added to the mxd.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;join the table to the polygon shapefile using the filed used in step 1.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;transfer the mean value to a field you created in the polygon shapefile using the field calculator.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;remove the join if you want.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Jun 2012 14:19:34 GMT</pubDate>
    <dc:creator>MarkBoucher</dc:creator>
    <dc:date>2012-06-20T14:19:34Z</dc:date>
    <item>
      <title>Spatial Analyst - calculate median raster values within polygons</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49550#M658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everyone, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a floating point elevation raster and a polygon shapefile representing vegetation classes. All I need to do is calculate the median elevation within each vegetation polygon. I thought the Zonal Statistics tool in Spatial Analyst would do this, but when i add my two layers, it removes the 'median' option from the 'Statistics type' field. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to accurately calculate the median raster value based on polygons? Does my elevation raster have to be an integer for this to work? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm sorry if this has been addressed before, I'm still getting used to the new forum layout...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Leah&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Apr 2010 02:29:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49550#M658</guid>
      <dc:creator>LeahHutchins</dc:creator>
      <dc:date>2010-04-07T02:29:01Z</dc:date>
    </item>
    <item>
      <title>Spatial Analyst - calculate median raster values within polygons</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49551#M659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;it removes the 'median' option from the 'Statistics type' field.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Leah,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is true that some statistical functions are not available with floating data. These are; MEDIAN, MAJORITY, MINORITY and VARIETY. Those functions require a histogram and this is not present with floating data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To avoid this you could convert your data to Integer. In order to reduce loss of precision you could multiply your raster with for instance 100 (e.g. express it in cm instead of m), perform the Zonal Statistics and divide the result with the same factor (e.g. 100). In Python this could look like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
from arcpy import env
from arcpy.sa import *
YourOutputRaster = Divide(Float(ZonalStatistics("YourZoneRaster","Value",Int(Times("YourFloatingDataRaster",100)),"MEDIAN","DATA")),100)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:54:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49551#M659</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-10T21:54:40Z</dc:date>
    </item>
    <item>
      <title>Spatial Analyst - calculate median raster values within polygons</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49552#M660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Xander, thank you so much! That worked perfectly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Apr 2010 08:30:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49552#M660</guid>
      <dc:creator>LeahHutchins</dc:creator>
      <dc:date>2010-04-07T08:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Analyst - calculate median raster values within polygons</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49553#M661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm sorry, but I don't undestrand something.. how do you calculate the mean with one raster and one polygon layer? I want to do something alike but I can't. When I click in "cell statistics", it only allows me to add raster layers...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 11:38:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49553#M661</guid>
      <dc:creator>marianaaraes</dc:creator>
      <dc:date>2012-06-20T11:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Analyst - calculate median raster values within polygons</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49554#M662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm sorry, but I don't undestrand something.. how do you calculate the mean with one raster and one polygon layer? I want to do something alike but I can't. When I click in "cell statistics", it only allows me to add raster layers...&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Leah, is using and referring to &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Zonal_Statistics/009z000000w7000000/"&gt;Zonal Statistics &lt;/A&gt;&lt;SPAN&gt; tool under Zonal toolset of Spatial Analyst. Please read usage section of Zonal Statistics tool for more information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 14:02:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49554#M662</guid>
      <dc:creator>TarunJaiswal</dc:creator>
      <dc:date>2012-06-20T14:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Analyst - calculate median raster values within polygons</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49555#M663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;The experts can correct me if I'm wrong, but another approach is to use Z&lt;/SPAN&gt;&lt;STRONG&gt;onal Statistics as Table&lt;/STRONG&gt;&lt;SPAN&gt;. This creates a table with all the stats in it. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Process:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;Run &lt;/SPAN&gt;&lt;STRONG style="line-height: 1.5;"&gt;Zonal Statistics as Table&lt;/STRONG&gt;&lt;SPAN style="line-height: 1.5;"&gt; choosing a unique field in the polygon shapefile (FID works).&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;the table with the statistics is added to the mxd.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;join the table to the polygon shapefile using the filed used in step 1.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;transfer the mean value to a field you created in the polygon shapefile using the field calculator.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="line-height: 1.5;"&gt;remove the join if you want.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 14:19:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/spatial-analyst-calculate-median-raster-values/m-p/49555#M663</guid>
      <dc:creator>MarkBoucher</dc:creator>
      <dc:date>2012-06-20T14:19:34Z</dc:date>
    </item>
  </channel>
</rss>

