<?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 Getting unexpected georeferencing after raster processing in numpy? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/getting-unexpected-georeferencing-after-raster/m-p/1267722#M6520</link>
    <description>&lt;P&gt;Hi, I'm attempting to run a simple canopy height model (CHM) using a surface and bare-earth terrain model.&amp;nbsp; I figured it would be quicker to do this in numpy, so I am using the RasterToNumPyArray methods in arcpy:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

arcpy.CheckOutExtensions('Spatial')
arcpy.env.overwriteOuptut = True

datadir = 'D:/Data'
dsm = os.path.join(datadir, 'dsm.tif')
dtm = os.path.join(datadir, 'dtm.tif')

arcpy.env.outputCoordinateSystem = dsm
arcpy.env.cellSize = dsm

dsm_arr = arcpy.RasterToNumPyArray(dsm, nodata_to_value=0)
dtm_arr = arcpy.RasterToNumPyArray(dtm, nodata_to_value=0)

diff_arr = dsm_arr - dtm_arr
# Set things below 2m difference to 0
diff_arr[diff_arr &amp;lt; 2] = 0

diff = arcpy.NumPyArrayToRaster(diff_arr, value_to_nodata=0)
diff.save(os.path.join(datadir, 'diff.tif'))

arcpy.CheckInExtension('Spatial')&lt;/LI-CODE&gt;&lt;P&gt;The result is that the diff.tif output is way off.&amp;nbsp; The cell sizes are right, the SRS remains the same, and relatively speaking the values are correct (it's dropping negligible values I don't care about), but the georeferencing is off by thousands of miles.&amp;nbsp; What am I doing wrong?&amp;nbsp; Do I need to explicitly feed in a corner or extent?&amp;nbsp; If so, how would I do that?&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2023 19:03:31 GMT</pubDate>
    <dc:creator>EricEagle</dc:creator>
    <dc:date>2023-03-14T19:03:31Z</dc:date>
    <item>
      <title>Getting unexpected georeferencing after raster processing in numpy?</title>
      <link>https://community.esri.com/t5/developers-questions/getting-unexpected-georeferencing-after-raster/m-p/1267722#M6520</link>
      <description>&lt;P&gt;Hi, I'm attempting to run a simple canopy height model (CHM) using a surface and bare-earth terrain model.&amp;nbsp; I figured it would be quicker to do this in numpy, so I am using the RasterToNumPyArray methods in arcpy:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

arcpy.CheckOutExtensions('Spatial')
arcpy.env.overwriteOuptut = True

datadir = 'D:/Data'
dsm = os.path.join(datadir, 'dsm.tif')
dtm = os.path.join(datadir, 'dtm.tif')

arcpy.env.outputCoordinateSystem = dsm
arcpy.env.cellSize = dsm

dsm_arr = arcpy.RasterToNumPyArray(dsm, nodata_to_value=0)
dtm_arr = arcpy.RasterToNumPyArray(dtm, nodata_to_value=0)

diff_arr = dsm_arr - dtm_arr
# Set things below 2m difference to 0
diff_arr[diff_arr &amp;lt; 2] = 0

diff = arcpy.NumPyArrayToRaster(diff_arr, value_to_nodata=0)
diff.save(os.path.join(datadir, 'diff.tif'))

arcpy.CheckInExtension('Spatial')&lt;/LI-CODE&gt;&lt;P&gt;The result is that the diff.tif output is way off.&amp;nbsp; The cell sizes are right, the SRS remains the same, and relatively speaking the values are correct (it's dropping negligible values I don't care about), but the georeferencing is off by thousands of miles.&amp;nbsp; What am I doing wrong?&amp;nbsp; Do I need to explicitly feed in a corner or extent?&amp;nbsp; If so, how would I do that?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 19:03:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/getting-unexpected-georeferencing-after-raster/m-p/1267722#M6520</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2023-03-14T19:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unexpected georeferencing after raster processing in numpy?</title>
      <link>https://community.esri.com/t5/developers-questions/getting-unexpected-georeferencing-after-raster/m-p/1267763#M6521</link>
      <description>&lt;P&gt;specify the lower left&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/numpyarraytoraster-function.htm" target="_blank"&gt;NumPyArrayToRaster—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;pnt = arcpy.Point(LL_X, LL_Y)
cell_size = # your cell size
no_data = # your nodata value or None
rast = arcpy.NumPyArrayToRaster(ai, pnt, cell_size, cell_size, no_data)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Mar 2023 20:07:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/getting-unexpected-georeferencing-after-raster/m-p/1267763#M6521</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-14T20:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unexpected georeferencing after raster processing in numpy?</title>
      <link>https://community.esri.com/t5/developers-questions/getting-unexpected-georeferencing-after-raster/m-p/1270358#M6534</link>
      <description>&lt;P&gt;Thanks Dan, that did the trick.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 13:29:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/getting-unexpected-georeferencing-after-raster/m-p/1270358#M6534</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2023-03-22T13:29:40Z</dc:date>
    </item>
  </channel>
</rss>

