NCSU GIS/MEA582:
Geospatial Modeling and Analysis

Geospatial Analysis I: global, zonal and focal operations, map algebra

Resources: ESRI Academy

Launch ArcGIS Pro and login with ArcGIS Online credentials if required. Select New> Map> Create New Project. Create a new project in your preferred workspace, in the instructions below we are using the default C:\Users\myname\Documents\ArcGIS\Projects\ folder.

Use your judgement to decide which maps to include in your report.

Compute zonal statistics for feature data

Add landuse feature class data.
In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
select 'landcl96'
'Ok'
RMC landcl96->'Attribute Table' in the Contents pane

Add a field (column) to the attribute table:

LMC Field, 'Add' along the top of the attribute window

Set Field Name to 'area_sq_meters' and Data Type to 'Double'
Click the 'X' on the fields tab to close the window.
Save changes

Calculate area (populate the area_sq_meters field):

RMC the column heading and select 'Calculate Field'
You will see the 'Calculate field' tool in the geoprocessing pane (this can also be searched like other geoprocessing tools)
Input=landcl96
Field=area_sq_meters
Expression type= python 3
Click on the empty acreage 'area_sq_meters=' field
double left click on Count to add it to the equation
Click on Multiply * button
Type in 812.25 (i.e. area of each cell in square meters) 
The field should now look like- !COUNT! * 812.25
Click 'Run'
Note the new values in the area_sq_meters field
Close the Table

Compute %area for each category in each zipcode zone. Add zipcode data:

In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
select 'zipcodes'
'Ok'

In the Geoprocessing pane, search for and select the 'Tabulate Area' tool
Set Input Raster or feature zone data to 'zipcodes'
Set Zone field to 'VALUE'
Set Input Raster or feature class data to 'landcl96'
Set Class field to 'VALUE'
Set Output Table to 'zip_sum'
Set Processing cell size to '28.5'
Click 'Run'

View the Tabulate results:

Look for a new 'Standalone Tables section at the bottom of the Contents pane
RMC zip_sum->Open
Explain how the data are presented.

Handling NULL data

Create a copy of SRTM DSM map, converting cells with elevation=0 to NULL:
In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
select 'elev_srt'
'Ok'
RMC elev_srt->Data->Export Raster
You will see the 'Export Raster' tool in the geoprocessing pane
Set Output raster dataset to 'elev_srt2'
Set the format to 'GRID'
Click 'Export'

Replace cells with elevation = 0 to nodata / NULL (i.e. -9999 for ArcGIS):

In the Geoprocessing pane, search for and select the 'Set Null' tool
Set Input Conditional Raster to 'elev_srt2'
Click the 'New Expression' button and modify to 'Where VALUE is equal to 0'
Set Input false raster or constant value to 'elev_srt2'
Set Output raster to .\Map_algebra\elev_srt3
Click 'Run'

Reclassification

Recode a 360-direction aspect map to 8 directions (D8):
In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
select 'aspect'
'Ok'
In the Geoprocessing pane, search for and select the 'Reclassify' tool
Set Input raster to 'aspect'
Leave Reclass field as 'VALUE'
Click the 'Classify' Button
Set the Classes to '8'
Click 'OK'
Set the Output Raster to 'aspect_d8'
Click 'Run'

Mosaicking

Patching raster data (often called mosaicking):
In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
(hold down control key to select multiple layers)
elid_782
elid_783
elid_792
elid_793
'Ok'
In the Geoprocessing pane, search for and select the 'Mosaic To New Raster' tool
Set Input Rasters to 'elid_782' , 'elid_783' , 'elid_792' , 'elid_793'
Set Output Location to your project gdb
Set Raster dataset name to 'elev_6m.tiff' (you do not need an extention for GDB rasters)
Set Spatial reference to match one of the inputs
Set Pixel type to 32_BIT_FLOAT
Set Number of Bands to 1
Leave the remaining fields as their defaults
Click 'Run'

Optional - have a look at the patched DEM in ArcScene.

Creating a subset

Create a subset of the map elevation for a subregion:
In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
Select 'ortho01'
Select 'elev'
In the Geoprocessing pane, search for and select the 'Extract by Mask' tool
Set Input Raster to 'elev'
Set Input raster of feature mask data to 'ortho01'
Set the out put raster to 'elev_mask'
Click 'Run'

Map Algebra

Compute Normalized Difference Vegetation Index (NDVI)

Explain the difference between FP and INT handling.
(Note: make sure you have spaces around operators (=,-,/) ).

In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
Select 'lsat7_40'
Select 'lsat7_30'
In the Geoprocessing pane, search for and select the 'Raster Calculator' tool
Type in the expression:
   ("lsat7_40" - "lsat7_30") / ("lsat7_40" + "lsat7_30")
   Set Output raster to 'ndvi1'
Click 'Run'
In the Geoprocessing pane, search for and select the 'Raster Calculator' tool
Type in the expression: 
   Float("lsat7_40" - "lsat7_30") / Float("lsat7_40" + "lsat7_30")
   Set Output raster to 'ndvi2'
Click 'Run'
Assign the ndvi2 map a color ramp that has green for high values

Compute the difference between the SRTM DSM and lidar-based NED DEM:

In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
Select 'elev_ned'
Select 'elev_srt'
In the Geoprocessing pane, search for and select the 'Raster Calculator' tool
Type in the expression: "elev_srt" - "elev_ned"  
Set Output raster to 'elev_diff'
Click 'Run'

Create a custom color table to distinguish the negative and positive values:

right click elev_diff->Symbology
Select a 'Red to Green' color scheme

Working with the conditional function

Create map of urban areas:
In the Map tab, in the Layer group, click 'Add Data'
Browse to C:\Users\myname\Documents\ArcGIS\582data\ncrast.gdb
Select 'landcl96' (this layer may already be present in your project)
In the Geoprocessing pane, search for and select the 'Raster Calculator' tool
Type in the expression: Con( ("landcl96" == 1) | ("landcl96" == 2),"landcl96",0)  
Set Output raster to 'calcmap5a'
Click 'Run'

Alternatively use the 'pick' tool:

In the Geoprocessing pane, search for and select the 'Pick' tool
Set input position raster to 'landcl96'
Set the input rasters as constant values: 1 and 2. 
Enter 1 and then 2 such that there are two entries (each value is on its own line).
Set output raster to 'urban_pick'
Click 'Run'

Handling null values

Create a map where all land use categories > 1 are set to null:

In the Geoprocessing pane, search for and select the 'Raster Calculator' tool
Type in the expression: SetNull( "landcl96" > 1, "landcl96" )     
Set output raster to 'developed'
Click 'Run'

Create mask for areas with elevation between 60 and 100m and land use 1 or 2:

In the Geoprocessing pane, search for and select the 'Raster Calculator' tool
Type in the expression: 
SetNull( (("elev" < 100) & ("elev" > 60)) & (("landcl96" == 1) | ("landcl96" == 2)), 1)
Set output raster to 'mask'
Click 'Run'