Thursday, September 21, 2023

New Tool - Align Rasters Toolbox for ArcGIS Pro Part II

This is the second in a two part series on the Align Rasters Toolbox. In this post I use a worked example to illustrate how the Align Rasters Toolbox works. I recently posted these tools as geoprocessing samples on the Esri website - https://www.arcgis.co/home/item.html?id=4f5e9d4e3b974890991d33e7e5251231

Aligning rasters such that their bounding extent and cell sizes match precisely is a tedious, time consuming, and challenging task. East-to-use tools have been lacking up until now. Many modeling approaches require rasters to be perfectly aligned. For example, a common workflow using R would be to stack rasters and then do subsequent predictive modeling using the stacked rasters as covariates. The Align Rasters Toolbox allows users to quickly and easily align rasters. It has options for working with rasters of differing cell sizes and extents.

Worked Example

The data in this example are available for download at –

https://nevada.box.com/s/dj1t250byrit9kux0244mktwvtlus8k4


Example 1 - Aligning Rasters without Expansion using the intersection method


 
In this first example we’re going to align an elevation, max temperature, and available soil water capacity raster for an area at Lake Tahoe. Each raster is a different cell size, and the AWC raster is in a geographic projection (WGS84) whereas the other two use a UTM projection (UTM 11 NAD83).




 

 

 

 

 

 

 

 


 

 

 

 


The images above show elevation (left), maximum temperature (center), and AWC (right).
We will create a template raster that represents the intersection of these three rasters using the Cell Statistics Tool in the Spatial Analyst Toolbox. In the Cell Statistics dialog enter the three rasters as the input rasters. Name the output c:\temp\CellStats.tif or something similar. Important – uncheck the “Ignore NoData in calculations” checkbox. Click the Environmental tab. Under Output Coordinates select Elevation.tif. Under Raster Analysis set cell size and snap raster to Elevation.tif. Click Run.



The resulting raster shows the intersection between all three rasters. You can see from the image below that it is most similar to elevation, but omits some of the northern portion of the original elevation raster.



 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

To check the overall raster spatial information right click on CellStats.tif, select properties, select source, and select raster information. As shown below you can see the cell size and the number of rows and columns. If you scroll down you can also view the bounding coordinates under Extent. In order for rasters to be aligned these three properties (number of columns and rows, cell size, bounding coordinates) need to match among all rasters.



 

 

 

 

 

Now run the Align Rasters without Expansion tool in the Align Rasters.atbx from the Catalog Window. Select the TestData folder as the input folder and Output1 as the output folder. Use the CellStats.tif as the template raster, cell size, and snap raster. Set the coordinate system to be the same as the template raster. Use any folder that you have write access to as the Temp folder. For example C:\temp.



 

 

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

The outputs should look like the three images above. Note that all three appear to have the same geographic extent. We can confirm that the number of rows, columns, cell size, and extent are the same by examining the properties. Right click on each layer, select properties, click on raster information. The number of rows and columns as well as the cell size should match for all three layers.  Click on Extent in the raster properties. The bounding coordinates should match between all three layers, however this is difficult to compare. Click on Spatial Reference and ensure that the coordinate system matches. You can see that the number of rows and columns for MaxTemp actually matches the other layers even though the output appears blocky. That is because the Align Rasters tool doesn’t do statistical downscaling. It simply lines the cells up.

We can use the Union tool on the footprints to ensure that all three rasters have the same geographic extent. Insert each of the three layers as an input into the Union tool. You can use default settings for the other parameters. Open the attribute table. If you see a single row that indicates that all three layers have the same extent.


 

 

 

 

 

 

 

 

 

 

 

Example 2 - Aligning Rasters with Expansion

This time a new raster called MaxTemp_Hole.tif has been added to demonstrate how the tool works to fill gaps and holes. The raster has been given a red-green color ramp to help illustrate the hole. This time we use the Align Rasters with Expansion tool. The default Max Neighborhood is 33x33 cells. Using the measure tool we see that the  gap that we need to cover is about 500 meters radius. Assuming that the template raster is 9-meter this means that only a 297 out of 500 meters will be filled. We can increase the Max Neighborhood to 99x99 to ensure that this gap gets filled.


The new raster appears to have the gap entirely filled. The shapefile footprint shows no hole as well. We can run the Union tool to ensure that all rasters are 100% identical in terms of extent as shown below. The single row in the unioned shapefile suggests that we succeeded in aligning the rasters properly.