AnsweredAssumed Answered

Arcpy RasterToNumPyArray Conversion Problem

Question asked by afriesz_USGS on Apr 5, 2017
Latest reply on Jun 29, 2017 by Dan_Patterson

I am executing arcpy commands from the python window in ArcMap 10.41. I am creating an arcpy Raster object using a raster layer from the table of contents. I want to then convert the raster object to a numpy array object so that I can run it through some scripted routines resulting in a raster output. With that said, I've noticed some odd behavior when creating the arcpy Raster object which seems to impact the creation of the numpy array object. 

 

The properties for the input raster layer are below. Note that the number of columns and rows is 4800 each.

 

After creating the raster object in the python window, I took a look at the height (rst.height) and width (rst.width) properties. To my surprise, they did not match. However, when I execute 'arcpy.Describe(rst).height' and 'arcpy.Describe(rst).width' I get 4800 for both (See image below). Can anyone explain this behavior?

Additionally, when I convert the raster object to a numpy array is get the dimensions (4800, 4799) which then carries over into any raster I make.

 

In the case of this raster layer, I'm losing the far right column during the conversions. In some over cases, I'm losing the bottom row of the raster layer. Initially I assumed the problem had something to do with the precision of the lat/lon values in the lower-left corner. After adjusting those I was able to get the correct number of rows and columns, but the data for the row or column that was missing initially was filled with nodata values.

 

Has anyone experienced and/or solved this before? 

Outcomes