Select to view content in your preferred language

Generalize a Slope Surface

2087
6
Jump to solution
03-30-2020 03:12 PM
JoeBorgione
MVP Emeritus

My adventure into creating and visualizing slope surfaces has moved into a third and possibly final chapter.  See Using arcpy to create slope surfaces  and Display A Slope Raster for chapters 1 and 2.  I have a complete slope surface for the Oquirrh Range ( pronounced oh-ker) which bounds the Salt Lake Valley to the west.  As you can imagine it took a bunch of data and a bunch of processing.  My goal in this whole exercise is to display where someone can build or can't build according to our slope ordinance which basically says, anything less than 25% is fair game; 25.1% to 35% you need to survey the property and show exactly where the building will take place, and finally anything steeper than 35% is off limits.

The complete slope model is now stored as a mosaic dataset, and the values range from 0% to 2535% .  I'd like to eventually end up with a polygon feature class that is depicts the three classifications described above.

1 = 'Go for it';

2 = 'Show us the survey' ;

3 = 'I can help the next person in line...'

  

My first question is generalizing the slope model to such a degree a reasonable approach? My second question is how do I make the calculations against the original slope? I'm not well versed in map algebra but what I do understand seems like a series of conditional statements such as:

if slope value <=25:
    new value = 1
else if slope value between 25 and 35:
    new value = 2
else:
    new value = 3  ‍‍‍‍‍‍

How is such conditional written in map algebra? Can that interim raster be held in memory and then output to a polygon feature class on disc? (I think I have enough ram...)

Or is there a better way to achieve my goal?

That should just about do it....
0 Kudos
1 Solution

Accepted Solutions
SteveLynch
Esri Regular Contributor

Joe

Another option is to rather use Reclassify. See the help for some examples, 

outReclassify = Reclassify(inRaster, reclassField, remap, "NODATA"),

outReclassify is temporary and can be passed into RasterToPolygon. You therefore will not need to persist the output via the .save as in the example.

As far as in memory goes, some questions;

  • ArcGIS Desktop or ArcGIS Pro (memory output is different between these 2)?
  • why in memory?
  • will this be done via scripting or from the tool UI?
  • what is the typical size of the output raster (number of columns and rows)?

-Steve

View solution in original post

6 Replies
SteveLynch
Esri Regular Contributor

Joe

Another option is to rather use Reclassify. See the help for some examples, 

outReclassify = Reclassify(inRaster, reclassField, remap, "NODATA"),

outReclassify is temporary and can be passed into RasterToPolygon. You therefore will not need to persist the output via the .save as in the example.

As far as in memory goes, some questions;

  • ArcGIS Desktop or ArcGIS Pro (memory output is different between these 2)?
  • why in memory?
  • will this be done via scripting or from the tool UI?
  • what is the typical size of the output raster (number of columns and rows)?

-Steve

DavidPike
MVP Frequent Contributor

As Steve says, Reclassify would be my go-to option. If you do need/want to cast it into memory:

sloperasterpath = r"c:\myraster.tif"

sloperasterobject = arcpy.Raster(rasterpath)

then do a Con(….) using map algebra syntax.

A useful part of the Reclassify tool is that if you change the symbology in the TOC to your desired classes, dragging that layer into the tool keeps those classified ranges.

0 Kudos
JoeBorgione
MVP Emeritus

Thanks guys. Steve Lynch‌: I thought I'd do it via python script and my thought was to hold whatever the interim raster would be in memory just because I don't need it. As mentioned, the raster I'm trying to simplify is in the form of a mosaic dataset and is 21,589 X 48,940 

I'll take a look at reclassify

Here is a hack I've tried: I made an int() type of raster out of the mosiac dataset and added a new field to integer-raster's and then made three successive selections base on the value field and calculated the new field accordingly.  That worked, I guess.  Then I performed a raster to polygon on it.  That's more or less what I want....

That should just about do it....
0 Kudos
curtvprice
MVP Esteemed Contributor

Joe, just a general note: my experience is if you can do a process within an Esri tool like Reclassify or raster functions  you really want to go that path as their tools are written in C++ allowing for a lot of optimization you can't do from the raster calculator or python scripting side of things, including nifty memory management, tiling and multiprocessing for many tools.

0 Kudos
DavidPike
MVP Frequent Contributor

Curtis, how is this implemented? Would be useful to expand my learning into C++ if this is the case.

Cheers

0 Kudos
NawajishNoman
Esri Contributor

Hi Joe,

You can also write a complex Con statement as follows:

mySlope = Raster(“mySlope.tif”)

mySlopeClasses = Con(mySlope <= 25, 1, Con(((mySlope > 25) & (mySlope <=35)), 2, 3))

mySlopeClasses.save(“mySlopeClasses.tif”)

Here is a blog on the Con tool you might find useful - Performing analysis with the Con tool

Thanks

Noman

Esri, Redlands, CA.