Before tackling this tutorial, you will need to download and install a dataset following these instructions:
Create a folder called MapAlgebraGlobal somewhere under your personal directory (e.g. C:\Users\jdoe\Documents\Tutorials\MapAlgebraGlobal\).
Download the data for this exercise then extract the contents of MapAlgebraGlobal.zip into your newly created MapAlgebraGlobal folder.
Make sure that you have the Spatial Analyst extension enabled for this exercise. For a refresher on how to enable the extension, click here.
Open the Zonal_Global.aprx map document.
The map displays the locations of Walmart stores across the United States. In this tutorial, we will explore the use of global and zonal raster operations. The objectives are to:
Calculate the euclidean distance to the nearest Walmart store across the entire country and introduce the concept of barriers,
Determine the percentage of the contiguous 48 states that lies within 20 km of a Walmart store,
Compute the average distance to the nearest Walmart store within each state.
The first step will therefore involve creating a euclidean distance raster layer from the point layer—a global operation.
NOTE:
Earlier versions of this tutorial made use of the Euclidean Distance tool. Esri plans to deprecate this tool in a future release of the software and is therefore recommending that the Distance Accumulation tool be used instead. This is the function used in this updated version of the tutorial.
In the Geoprocessing search window, type Distance Accumulation .
Click on the Distance Accumulation tool associated with the Spatial Analyst extension.
Set the input feature source to Walmarts.
Name the output raster Distance2Walmarts.tif.
Do not save a .tif file in a geodatabse, instead be sure to place it in the project folder.
Recall from earlier tutorials that raster files can be stored in many different file formats such as .img or .tif. You must therefore explicitly define the raster file format with the filename extension. In this tutorial, we'll stick with the .tif file format.
Don't click Run just yet!
The output raster will adopt the same extent used to define the Walmarts point layer extent (the input layer in this example). Therefore, not all parts of the contiguous US states will have a pixel value (the point layer's extent is smaller than the States layer's extent) . To change the output extent, you can define a different output extent in the Environments settings.
Click on the Environments tab.
Under Processing Extent, click on the layers pull-down menu and select the States layer.
The States layer encompasses all of the 48 states. This will ensure that the output raster will cover the same extent as that of the States layer.
You'll note that the Environments settings will also allow you to define the desired output coordinate system. By default, the output will inherit the input point layer's coordinate system (and not that of the map).
Because we are creating a new raster from scratch, we should also explicitly define the pixel dimension. In this tutorial we will adopt a 4 km (4,000 m) pixel size.
While still in the Environments tab, type 4000 in the Cell Size field under the Raster Analysis rubric.
Given that the tool does not offer an option to specify the cell size units, we must assume that the tool will adopt the units associated with the layer's coordinate system (meters in this example).
We'll also define the mask. The mask is used to assign NoData values to pixels outside of a defined boundary. Here, we'll set the boundary to the States layer.
Set the Mask to States.
Click Run to generate the Euclidean distance raster.
Note that the mask option will restrict the input points to the extent defined by the mask, this is not a problem here since the mask encompasses all the points. However, if input points or features are outside of the mask, it’s best to leave the mask field blank and clip the output euclidean distance raster output using the Extract by Mask tool.
Don't forget to turn off any overlying polygon layers in the Contents pane to view the output raster since the raster will be added to the bottom of the stack.
NOTE:
Each pixel of the output raster displays its distance to the closest Walmart point feature. The distance units are those of the layer's coordinate system (meters in this example). Distance is sensitive to the coordinate system used (i.e. you should choose one that preserves distance)! If you are unsure if your coordinate system preserves distance, and if computational resources are not an issue, you should adopt the geodesic method of distance measurement over the default planar method.
Next, you will identify all locations (pixels) that are within 20 km of a Walmart.
We'll reclassify the euclidean distance raster to binary values: 0’s for distances greater than 20 km and 1’s for distances less than or equal to 20 km. There are at least two ways in which this step can be accomplished: one approach is to use the Raster Calculator tool and the other is to use the Reclassify tool (see the Local Operations tutorial for a refresher). Regardless which method you choose to use, name the output raster Dist20k.tif.
In this example, we'll use the Raster Calculator tool.
Open the Raster Calculator tool.
Define the expression as:
Con("Distance2Walmarts.tif" <= 20000, 1, 0)
Note the upper case "C" in "Con" (the function is case sensitive).
Name the output raster Dist20k.tif.
Click Run.
The output map is a binary raster. As such, it has an attribute table listing the number of 0 and 1 pixels in the raster.
From these values we can compute the percentage of all locations within the 48 states that are within 20 km of a nearest Walmart, or 143,559 / (359,573 + 143,559 ) = 28.5%.
Euclidean distance provides only a rough approximation of travel distance to Walmart stores because road and sidewalk networks are often complex, and physical barriers like waterways can prevent direct access. However, the Euclidean distance measure can be improved by incorporating barriers into the analysis.
In this example, major rivers will be used as barriers. Because most rivers can be crossed via bridges, the Rivers layer provided in the Contents pane includes discontinuities along river features. These breaks are intended to mimic cross-river access at major bridge locations resulting in a more realistic representation of travel accessibility than a simple straight-line distance measure.
Turn on the River layer.
If you zoom in on several Walmart locations near river segments, you will notice discontinuities along some of these segments. These intentional breaks represent locations where river crossings are possible, such as major bridges.
We will now re-run the Distance Accumulation tool using the Rivers layer as a barrier.
Open the Distance Accumulation tool.
Re-enter the initial parameters while not forgetting to set the Environment variables such as extent and pixel size.
Add the rivers layer to the Input Raster or Feature Barriers field.
Name the output Distance2Walmarts_river.tif
Click Run
By incorporating rivers into the analysis, distance accumulation is forced to circumvent river segments except at designated crossing points. The resulting distance-to-Walmart raster provides a more realistic representation of accessibility than a simple Euclidean distance surface.
The Distance Accumulation tool can accept as input barrier discrete polygons, polylines and rasters where non-NULL pixel values are used as a barriers.
In this next step, you will learn how to summarize pixel values by polygon features (e.g. States layer) using a zonal operation.
Note that zonal operations should be performed on coordinate systems that preserve area so as to ensure proper representation of all locations within each polygon.
For brevity, we'll assume that this coordinate system does a decent job in preserving area for this tutorial, but in practice, you would want to reproject the layers to a coordinate system that preserves area.
Open the Zonal Statistics as Table geoprocessing tool (open the one associated with the Spatial Analyst extension).
The zone layer can be either a raster or a vector. In this working example, we will use the States vector layer as the feature zone data.
Set the Zone field to Name (this will be the input field name that will populate the output table).
Set the input value raster to Distance2Walmarts_river.tif.
Keep the default output table name (ZonalSt_States1 in this example) and location (the project's geodatabase)--this is the default location for the table.
ArcGIS will not directly export to a CSV or Excel file from this geoprocess. The only valid output format outside of a geodatabase is a .dbf file.
Click Run.
Open the newly created table to view its contents.
For each polygon in the States layer, a set of distance-to-Walmart summary statistics is tabulated. The output table copies the Name column from the input States layer—this will allow us to join this table back to the States vector layer in the following step.
Note that the zonal statistics tool adds a Count column giving the total number of pixels covered by each state and the total (surface) Area covered by those pixels in the layer's coordinate system units (meters in our working example).
Using techniques covered in the Joining tables tutorial, join this table back to the States layer, then symbolize the features by Mean distance to the closest Walmart. You might need to export the joined layer to a new shapefile to successfully symbolize the Mean value.
This wraps up this exercise.