Export numerical arrays from ArcGIS rasters.

1164
8
11-27-2018 04:52 PM
MichaelBurnam-Fink
New Contributor

Hello, I'm a data scientist, new to GIS, and I am having tremendous difficulty getting data out of ArcGIS.

I'm going to describe my workflow and indicate the specific problems I am having in italics

In the broadest terms, I am interested in modeling wildfire using deep learning.  To do, I have accessed fuel load and topological data from Landfire.gov (raster files), wildfire perimeters from geomac.gov (shape files), and wind and precipitation data from NOAA (flat text). I am trying to create numerical arrays of the terrain and fuel loads in the neighborhood of historic wildfires, which would be amenable to machine learning techniques.

I have successfully imported all data into an ArcGIS Pro project and map. An example fire looks this, with the fire above the slope layer of the Landfire data.  Very pretty!

I cannot figure out how to export or access this data at any level more detailed than a one layer .png

When I try to export a .tiff file using the Raster Layer >> Data >> Export Raster tool, I get a file that cannot be read or opened by any other program.  

Alternatively, I have tried to use the arcgis python library, but arcgis is so focused on cloud and web application that I can't even open a .aprx project file stored locally on my machine. 

I am especially frustrated, because these appear to be solvable tasks in older ESRI products like ArcMap and arcpy which are no longer support or available. 

Tags (1)
0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

You probably need to go from vector to raster to get anything suitable. (easily done)

Once you have a raster, to get it into an array format for use in scipy, numpy and the *py stack or to other formats,

RasterToNumPyArray—ArcPy Functions | ArcGIS Desktop 

is my goto, assuming it is more than a pretty picture to begin with.  

You can make an array stack or if in a pinch convert the 'picture' to grey-scale.

What format do you want to work in?  I have used 'tifffile' to read-write numpy arrays from/to *.tif file formats. netcdf, hdf etc are also other formats, but numpy arrays should get you most places 

MichaelBurnam-Fink
New Contributor

Thank you, Dan, that proved immensely helpful!

One last problem.  RasterToNumPyArray takes in an arcPy.Point object.  I'm not sure what coordinates it uses, but it's not Lat-Long.  I have a list of bounding boxes, defined by a lower left corner in longitude and latitude, and then a number of pixel rows and columns.  

How do I find out what coordinate system ArcGIS is in, and get that initial point?

0 Kudos
DanPatterson_Retired
MVP Emeritus

arcpy.Point(Longval, Latval+deltaXtoMakeItHeadNorth)

if your raster is in decimal degrees, then you have to specify the coordinate in long lat.   Go from there.  It will want the cell size in X and Y, so in your case you need to know that or figure it out from the extent

0 Kudos
MichaelBurnam-Fink
New Contributor

That is exactly the problem.  I'm using Landfire data, which is in a NAD 1983 Conic Albers projection and a standard LANDSAT 30 m raster.

However, arcpy.Point() is reading the grid in meters relative to (96 W, 23 N).  I know this, because the GoTo XY takes me to that point, and entering 30 m increments into GoToXY and RasterToNumPyArray moves everything one grid cell.

Weirdly, finding the haversine distance between the two points gives me values that are clearly wrong. 

What I'd like to do is go from Lat-Long to whatever arcpy.Point() understands, either in ArcGIS's python interpreter or my own notebook.

0 Kudos
DanPatterson_Retired
MVP Emeritus

What is the coordinate system of the map?  The first layer you add sets it to whatever.  That may be the issue.

When you bring in the array specifying the top left corner, you aren't done.  You still have to define its projection in order for it to 'project-on-the-fly' to match whatever the map is in.

It is best to do this kind of stuff in an empty map... no data... no basemap.  Get it established, define its coordinate system, then add it into other maps and it should play nice with the other data.

0 Kudos
MichaelBurnam-Fink
New Contributor

I'm really not sure.  I believe the coordinate reference system is EPSG: 4269, which I set by right clicking on Maps in the Contents toolbar, going to Properties at the bottom of the menu that appears, and then searching for EPSG 4269, clicking the US NAD Albers projection that shows up, and then hitting 'okay'.  It appears to work, in that the map is flat rather than bent, and moving along lines of longitude trace arcs.

How do I switch layers to the projection I want to use?

0 Kudos
MichaelBurnam-Fink
New Contributor

I GOT IT!!!

The Landfire rasters are displayed in EPSG 5070. I can do a coordinate transformation on the geomac shape files, which are in EPSG 4269, with a single line of code.

Dan, you're great, I owe you a beer.  ArcGIS, why is this information not visible anywhere?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Glad it worked out Michael

0 Kudos