<?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 kernel density in ArcGIS API for Python - how do I work with the results? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/kernel-density-in-arcgis-api-for-python-how-do-i/m-p/1169078#M7346</link>
    <description>&lt;P&gt;I'm trying to run&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcgis.raster.functions.gbl.kernel_density&lt;/FONT&gt;&amp;nbsp;(&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.raster.functions.gbl.html#kernel-density" target="_self"&gt;link to docs&lt;/A&gt;). I think I'm running it ok, but I have no idea what to do with the output! The docs just say you get an output raster, no samples included, and even Google search doesn't turn up much.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create an input like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS
import arcgis
gis = GIS(profile="AGOL")
points_item = gis.content.get('abcdefg123456...')
points_fl = arcgis.features.FeatureLayer(points_item)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried running kernel density with the feature layer &lt;FONT face="courier new,courier" color="#993300"&gt;points_fl&lt;/FONT&gt;, but it only works if I use&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;points_item&lt;/FONT&gt;&amp;nbsp;as the input. That seems odd, but it works, or at least it stops giving me an error.&amp;nbsp; Here is what I'm trying:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;out_raster = arcgis.raster.functions.gbl.kernel_density(
    points_item, '&amp;lt;fieldname&amp;gt;', cell_size=1000, search_radius=2000, 
    area_unit_scale_factor='SQUARE_MAP_UNITS', out_cell_values='DENSITIES', 
    method='PLANAR', in_barriers=None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have confirmed that the Kernel Density GP tool in Pro works with this data set and these settings, so my inputs and parameters are valid as far as I can tell. If I do a &lt;FONT face="courier new,courier" color="#993300"&gt;type(out_raster)&lt;/FONT&gt;, I get&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcgis.raster._layer.ImageryLayer&lt;/FONT&gt;. With any attempt to find out about this raster, I get an error. Something as simple as trying to print&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;out_raster.raster_info&lt;/FONT&gt; gives my a lengthy traceback, but this is the crux of it:&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" color="#993300"&gt;Exception: Invalid or missing input parameters.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#993300"&gt;Authentication token required. (status code 499).&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#993300"&gt;(Error Code: 400)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Same for trying to access the columns or rows properties, which seem like pretty basic things you should be able to find out about a raster. Interestingly, if I try this in an AGOL notebook where I definitely should be signed in, I get the same error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Can anyone tell me how to work with kernel density output and what I can do with it? So far, I just know kernel density ran and didn't fail, but have no idea how to do anything with the output.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Side note:&amp;nbsp;I am also unable to run the&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;out_raster.save()&lt;/FONT&gt;&amp;nbsp;function. I also get a large traceback, but the main error is "&lt;FONT face="courier new,courier" color="#993300"&gt;RuntimeError: Unable to create service&lt;/FONT&gt;". I think I am just missing a role to create imagery services or something, because I lack any option to create them in Pro or on the AGOL website. I'm going to work on that before I worry about this part of it...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 22:03:27 GMT</pubDate>
    <dc:creator>davedoesgis</dc:creator>
    <dc:date>2022-04-28T22:03:27Z</dc:date>
    <item>
      <title>kernel density in ArcGIS API for Python - how do I work with the results?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/kernel-density-in-arcgis-api-for-python-how-do-i/m-p/1169078#M7346</link>
      <description>&lt;P&gt;I'm trying to run&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcgis.raster.functions.gbl.kernel_density&lt;/FONT&gt;&amp;nbsp;(&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.raster.functions.gbl.html#kernel-density" target="_self"&gt;link to docs&lt;/A&gt;). I think I'm running it ok, but I have no idea what to do with the output! The docs just say you get an output raster, no samples included, and even Google search doesn't turn up much.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create an input like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS
import arcgis
gis = GIS(profile="AGOL")
points_item = gis.content.get('abcdefg123456...')
points_fl = arcgis.features.FeatureLayer(points_item)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried running kernel density with the feature layer &lt;FONT face="courier new,courier" color="#993300"&gt;points_fl&lt;/FONT&gt;, but it only works if I use&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;points_item&lt;/FONT&gt;&amp;nbsp;as the input. That seems odd, but it works, or at least it stops giving me an error.&amp;nbsp; Here is what I'm trying:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;out_raster = arcgis.raster.functions.gbl.kernel_density(
    points_item, '&amp;lt;fieldname&amp;gt;', cell_size=1000, search_radius=2000, 
    area_unit_scale_factor='SQUARE_MAP_UNITS', out_cell_values='DENSITIES', 
    method='PLANAR', in_barriers=None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have confirmed that the Kernel Density GP tool in Pro works with this data set and these settings, so my inputs and parameters are valid as far as I can tell. If I do a &lt;FONT face="courier new,courier" color="#993300"&gt;type(out_raster)&lt;/FONT&gt;, I get&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcgis.raster._layer.ImageryLayer&lt;/FONT&gt;. With any attempt to find out about this raster, I get an error. Something as simple as trying to print&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;out_raster.raster_info&lt;/FONT&gt; gives my a lengthy traceback, but this is the crux of it:&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" color="#993300"&gt;Exception: Invalid or missing input parameters.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#993300"&gt;Authentication token required. (status code 499).&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#993300"&gt;(Error Code: 400)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Same for trying to access the columns or rows properties, which seem like pretty basic things you should be able to find out about a raster. Interestingly, if I try this in an AGOL notebook where I definitely should be signed in, I get the same error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Can anyone tell me how to work with kernel density output and what I can do with it? So far, I just know kernel density ran and didn't fail, but have no idea how to do anything with the output.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Side note:&amp;nbsp;I am also unable to run the&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;out_raster.save()&lt;/FONT&gt;&amp;nbsp;function. I also get a large traceback, but the main error is "&lt;FONT face="courier new,courier" color="#993300"&gt;RuntimeError: Unable to create service&lt;/FONT&gt;". I think I am just missing a role to create imagery services or something, because I lack any option to create them in Pro or on the AGOL website. I'm going to work on that before I worry about this part of it...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 22:03:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/kernel-density-in-arcgis-api-for-python-how-do-i/m-p/1169078#M7346</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2022-04-28T22:03:27Z</dc:date>
    </item>
  </channel>
</rss>

