GEO 428: Raster Analysis II Tuesday, October 16, 2012 Input raster may require reclassification May be done by multiplying by a scalar - DEM = DEM - 25 May also require an either/or function Ex: Identify all cells in the DEM higher than 600 m. Conditional Statements If... then... else... If (DEM > 600, out = 1, else out = 0) - Is this local, focal, or something else? In GRASS New Grid = if(conditional, true, false) r.mapcalc 'Outgrid = if(dem > 600, 1, 0)' In ArcGIS/ArcGrid New Grid = CON(conditional, true, false) Outgrid = CON(DEM > 600, 1, 0) Masking Portions of a Raster Suppose we want to evaluate landslide risk for urban areas in a study Need to remove (mask) risk from all other areas How can this be done using a conditional? Answer urbrisk = if(lc == 4, sliderisk, 0) Multiple grids can be used in a statement Setting NULL GRASS: Must explicitly set null urbrisk = if(lc == 4, sliderisk, null()) ArcGIS/ ArcGRID: If no false argument is provided, output cell gets NODATA value urbrisk = CON(LC == 4, sliderisk) Complex Conditionals Elevations between 600 700 m needed. Conditional looks like this: If (DEM > 600 AND < 700, out = 1, else out = 0) GRASS Approaches Nested if functions out = if(dem > 600, if(dem < 700, 1, 0), 0) Compound condition statement out = if(dem > 600 && DEM < 700, 1, 0) ArcGRID Approaches Nested CON Commands out = CON(DEM > 600, CON(DEM < 700, 1, 0), 0) Nested Conditional Statements out = CON(DEM > 600, DEM < 700, 1, 0, 0) Compound condition statement out = CON(DEM > 600 & DEM < 700, 1, 0) Key is making sure all the arguments are there!
Buffering Not as clear as in vector Entire cell must be in or out Two approaches Expand a class out a set number of cells r.grow (GRASS) Calculate distance from a set of cells, then classify distance based on cutoff r.grow.distance (GRASS) Buffer Examples 1. Growing or Expanding Expands around features (non-null cells) Growth radius in cells, NOT ground distance! 2. Distance / Reclass First calculate distance around features (non-null) Then use conditional to extract target distances Project Design & Management Analysis may involve many steps How to plan these steps? How to organize work? How to communicate process to others? Stages of Management Identify project objectives Develop plan for attaining them efficiently Mobilize resources Identify and get appropriate data Set aside sufficient time, etc. Execute the plan Evaluate results, repeat as necessary Plan Design Raster analysis well-suited to flow charts Raster grids are rectangles Input data / intermediate steps / final results Grids connected by arrows Identifies task flow Arrows are functions / operations A Simple Example Objective: determine all south facing locations South = 225 315 degrees (GRASS!) Needed Data: DEM Tasks Calculate Aspect from DEM Reclassify Aspect so that Locations facing between 225-315 equal 1 Other locations equal 0
Results Aspect Reclassified via: Out = if(asp > 225 & asp < 315, 1, 0) Extended Example Objective: ID Areas Suitable for Logging Criteria: Jackpine forest only Not within 500m of water Low Slopes (< 5%) Well drained soils Available Data 2.5 km x 2.5 km area 500m resolution Layer 1: Lake 1 = Lake 0 = No lake Layer 2: Forest Species 1 = Black Spruce 2 = Jackpine 3 = No forest Layer 3: Elevation (meters) Layer 4: Soil Drainage 0 = waterlogged 1 = poor 2 = good Unary Steps Buffer / Spread 1 to near lake (1.1) Then get inverse for away from lake (1.2) Reclassify 2 to loggable species (2.1) Calculate slope from 3 (3.1) Reclassify Slope to low / high (3.2) Reclassify 4 to well-drained (4.1) Binary Steps Intersect away from lake with species 1.2 overlain with 2.1 (5) Intersect (overlay) low slopes with soils 3.2 overlain with 4.1 (6) Intersect species/soils with away/slopes 5 overlain with 6 (7) Result (7) is a suitability map! Flow Diagram of Project 1 1 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 2 2 0 2 0 1 1 1 2 2 2 1 1 180 180 250 290 280 180 180 200 230 250 180 190 200 220 240 190 210 200 220 230 190 220 230 260 290 0 0 2 2 2 0 2 1 1 2 1 2 1 2 2
Obtaining 'away from lake' Calculate distance from lake r.grow.distance -> dist_11 Use conditional function If (lake_dist > 1, out = 1, else out = 0) Away_12 = if(dist_11 > 1, 1, 0) Alternative Approach Calculate buffer of 1 around lake r.grow -> buff_ll Then swap the 1's and 0's Use conditional statement Away_12 = if(buff_11 == 1, 1, 0) OR, do some math Away_12 = 1 buff_11 Obtaining 'loggable species' Use conditional function If (species_2 = 2, out = 1, else out = 0) Pine_21 = if(species_2 == 2, 1, 0) Obtaining 'low slope' Calculate percent slope r.slope.aspect -> Perslope_31 (in percent!) Reclassify slope map using conditional Lowslope_32 = if(perslope < 5, 1, 0) Obtaining 'well drained' Use conditional function If (drain_4 = 2, out = 1, else out = 0) Welld_41 = if(drain_4 == 2, 1, 0) 0 0 1 2 3 0 0 1 2 3 0 1 1.4 2.2 3.2 1 1.4 2.2 2.8 3.6 2 2.2 2.8 3.6 4.2 0 1 1 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 0 1 1 1 0 0 0 Intersections To intersect two binary raster grid layers logical AND operation Multiply them together! 1 x 1 = 1 1 x 0 = 0 0 x 1 = 0 0 x 0 = 0 Intersection 1 Intersect away_12 with pine_21 Suit_5 = away_12 * pine_21 Intersection 2 Intersect lowslope_32 with welld_41 Suit_6 = lowslope_32 * welld_41 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 0 1 0 0 0
Intersection 3 Intersect suit_5 with suit_6 Logsites_7 = suit_5 * suit_6 Final Results: 2 locations are suitable! 0 1 0 0 0 Flow Diagram Hood River Project Study area in Oregon along Columbia River 1:250k DEM, LULC Dataset The Dalles (w) quadrangle Projected, moved to common reference system Project Identify potential sites for housing development near Hood River, OR. Objectives Low slope (less than 5%) Agricultural Land Within 2000 m. of River Input Data Flow Diagram Low Slope per_slope <- r.slope.aspect (percent) low_slope = if(per_slope < 5, 1, 0) Agriculture ag = if(lu ==2, 1, 0) Close to River River = if(lu == 5, null()) GRASS: null() = NODATA r.grow.distance (input=river, distance=rivdist) near_riv = if(rivdist < 2000, 1, 0) Results Weighting Analysis Discussion has focused on Boolean Analysis 1's and 0's Often range of Weights may be better Cells with higher weights have more influence Themes with larger weights have more influence Use Addition, not Multiplication
Example Habitat Suitability: Elevation > 250 m. is best Elevation between 220 and 250 is ok Elevation between 200 and 220 is poor Elevation < 200 is unacceptable Determining Weights Law, Regulation, or Physical Requirement EPA Guidelines Temperature Elevation relationship Species Range of tolerance Expert Opinion Use of multiple weighting schemes Compare results Determine how different they are 0 0 2 3 3 0 1 1 1 2 0 1 2 3 3 0 0 4 9 9 0 0 1 4 4 0 0 1 4 4 0 1 1 1 4 0 1 4 9 9 Effect of Weights Elevation Range example If DEM only factor, cell values may be changed by weighting Changes influence if other raster layers also used Then grids with relatively higher weights influence outcome more Allows some themes to be more important than others Operation Change Add - don't multiply! Mixing Weights with Boolean In logging example Jackpine preferable to spruce (2, 1) Well-drained preferable to poorly drained (2, 1) Saturated soil NOT an option No Forest NOT an option How to combine? Example Boolean & Weights Create no forest / forest map Create not saturated / saturated map Bool = Forest * Not_Sat Suit = ( Species + Drain ) * Bool Weighted Logging Example Objective: Find most desirable locations for logging Use data below, same criteria as in example Forest species twice as important as drainage! Construct flow diagram include the algebra! Calculate answer Answer 0 0 1 1 0 1 0 1 1 1 0 0 2 2 0 2 0 1 1 1 2 2 2 1 1 0 1 1 1 1 0 0 2 2 0 2 0 1 1 1 2 2 2 1 1 0 1 1 1 1 0 0 2 2 2 0 2 1 1 2 1 2 1 2 2 0 0 6 6 2 0 0 3 5 6 0 0 3 3 4 0 6 5 3 4 3 4 3 0 0 0 0 2 2 2 0 2 1 1 2 1 2 1 2 2 0 0 4 4 2 0 0 2 3 4 0 0 2 2 3 0 4 3 2 3 2 3 2 0 0
Weighted Habitat Example Saginaw Creeper Habitat Identification Only found on north-facing slopes Likes elevations between 150-250 meters Can live on agricultural land, but: 3x more likely to be in forests Data DEM Land Cover: 1:urban, 2:ag, 3:pinefor, 4:oakfor Answer Ambiguous Combinations Consider a land cover change problem Land Cover (1978) vs Land Cover (2000) Classes: 1 (forest), 2 (ag), 3 (urban) How to id those areas that have changed? 0 = no change, 1 = changed Landcover Change LCDIFF = LC78 LC2K CHANGE = if (LCDIFF == 0, 0, 1) 0 = No Change; Any other number = Change What does -1 stand for in LCDiff? 1978 1 1 1 2 2 1 1 1 2 2 2 3 3 2 1 2 3 3 2 1 1 1 2 2 2 LCDiff 0 0 0 1 0 0-2 0 0 0-1 0 0-1 -1 1 0 0 0-1 0 0 1 0 1 2000 1 1 1 1 2 1 3 1 2 2 3 3 3 3 2 1 3 3 2 2 1 1 1 2 1 Avoiding Ambiguity Reclass one input raster so values are very different, e.g.: LC78B = LC78 * 10 DIFFB = LC78B LC2K Resulting values are non-ambiguous Also see r.cross in GRASS Summary Conditional Functions Masking (Zonal Stuff) Buffering Rasters Managing Spatial Analysis Flow Diagrams for Raster Analysis Example Applications Weighting Inputs Differently Avoiding Ambiguity in change LC78B 10 10 10 20 20 10 10 10 20 20 20 30 30 20 10 20 30 30 20 10 10 10 20 20 20 2000 1 1 1 1 2 1 3 1 2 2 3 3 3 3 2 1 3 3 2 2 1 1 1 2 1 DIFFB 09 09 09 19 18 09 07 09 18 18 17 27 27 17 08 19 27 27 18 08 09 09 19 18 19