GeoEco.DataManagement.ArcGISRasters.ArcGISRaster.ToNumpyArray

classmethod ArcGISRaster.ToNumpyArray(raster, band=1)

Reads an ArcGIS raster or raster layer into a numpy array.

Requires: ArcGIS Pro 3.2.0 or later or ArcGIS Server equivalent to ArcGIS Pro 3.2.0 or later, Python numpy module.

Parameters:
  • raster (str) – Raster to read. Minimum length꞉ 1. Must exist.

  • band (int, optional) – Band number to read, starting with 1. Minimum value꞉ 1.

Returns:

A two-item tuple consisting of the numpy array read from the raster and the value in that array that represents NoData.

Note

For integer rasters, the numpy array will use the most compact data type that can represent all of the values in the raster. Normally, ArcGIS automatically selects the most compact data type, but this does not always happen. For example, I have seen ArcGIS store data ranging from 0 to 65535 (with no NoData value) as an int32 raster even though a uint16 is the most compact data type for that range. If the numpy array is compacted, the NoData value may be different than what ArcGIS used when it created the raster.

Return type:

tuple of object