Clip DEM by elevation AND EXCLUDE islands outside of contiguous mass.

3042
8
12-01-2010 10:09 AM
RyanHollamby
New Contributor
I am trying to avoid digitizing a shapefile around my study area and then clipping the DEM by the shapefile. Reason I am trying to avoid this is because I am talking about a extremely large area. Digitizing the shapefile to the area would take weeks.

I have a DEM clipped to show everything 3,000 meters and higher. I have a contiguous mass that stays inbounds of 3,000 meters but then have outliers around the contiguous mass. I need to figure out a way to get rid of these 'islands'.

Below is the small dataset that I am working on. My study area only includes the large contiguous mass. How do I get rid of those outliers?

0 Kudos
8 Replies
NiklasNorrthon
Occasional Contributor III
Run these tools in this order:

Con (input_raster Value > 3000 1 0 output_raster)
RasterToPolygon
Select (Shape_Area > some value)

Or if you don't have Spatial Analyst, but ArcGIS 10 (ArcEditor), play with the MosaicDataset functions to get the same effect as the Con tool.

Or if you don't have that either, convert your grid to Ascii, and you python or something to get the same effect as the Con tool.
0 Kudos
RyanHollamby
New Contributor
Run these tools in this order:

Con (input_raster Value > 3000 1 0 output_raster)
RasterToPolygon
Select (Shape_Area > some value)



I am using ArcMap 10 with all the extensions, just FYI.


I am slightly confused how the Select (Shape_Area > some value) works. Sorry for being ignorant on this topic. I would appreciate the help.

Thank You,
Ryan
0 Kudos
NiklasNorrthon
Occasional Contributor III
import arcpy
import arcpy.sa

arcpy.CheckOutExtension('Spatial')

elev = r'C:\some\path\to\elevation\data.gdb\elevation'
tmp_poly = r'C:\some\path\to\elevation\data.gdb\tmp'
dest = r'C:\some\path\to\elevation\data.gdb\out_features'

elev_value = 3000

r = arcpy.sa.Raster(elev)

r_high = arcpy.sa.Con(r, 1, 0, 'VALUE >= %d' % elev_value)
arcpy.conversion.RasterToPolygon(r_high, tmp_poly, True)
arcpy.analysis.Select(tmp_poly, dest, 'Shape_area > %d' % elev_value)
                        
0 Kudos
RyanHollamby
New Contributor
First off niklas.norrthon thanks for the help on this.

The study area is converted to a polygon with everything 3,000 meters and higher (which many of the islands are). Is the DEM clipped to show 3,000 above the same as the con tool 3,000 above?

But can't not figure out the shape area part. I'm wondering if I messed up with the polygon. The polygon doesn't have any attributes, and acts as a single polygon. With the conversion that you mention should there be multiple polygons?

Thanks!
0 Kudos
NiklasNorrthon
Occasional Contributor III
The Con (stands for conditional) tool gives you a boolean raster with values 1 for grid cells with values exceeding 3000, and 0 for grid cells below 3000.

The RasterToPolygon tool should give you a feature class, with one feature for each contiguous area of either ones or zeroes. If you store that feature class in a geodatabase (file or sde), there should be a Shape_length field and a Shape_area field that are automatically calculated for you.

Try these steps manually with different values for input and see what you get. You could also try the RasterToPolygon tool without running Con before, that should give you one polygon for each contiguous area of each elevation value in the original.

One thing to notice is that if you want the area calculated for you, you should avoid shape files.
0 Kudos
RyanHollamby
New Contributor
The Con (stands for conditional) tool gives you a boolean raster with values 1 for grid cells with values exceeding 3000, and 0 for grid cells below 3000.

The RasterToPolygon tool should give you a feature class, with one feature for each contiguous area of either ones or zeroes. If you store that feature class in a geodatabase (file or sde), there should be a Shape_length field and a Shape_area field that are automatically calculated for you.

Try these steps manually with different values for input and see what you get. You could also try the RasterToPolygon tool without running Con before, that should give you one polygon for each contiguous area of each elevation value in the original.

One thing to notice is that if you want the area calculated for you, you should avoid shape files.


The raster dem depicted in the first post, is everything 3,000 meters or higher. So I think that did what the Con tool is doing (?).

The only thing that I want to use the shapefile for is to clip the DEM. I have a tool that will calculate the area from the DEM. So I just need the shapfile for the clip, then I am deleting it. If I could just create a shapefile that I can simply select the large whole mass, this part would be done.

I will try your recommendations, thank you for your help and tips.

Thanks!
Ryan
0 Kudos
NiklasNorrthon
Occasional Contributor III
The reason I suggested the Con tool is to get only two possible raster values: Above 3000 and below 3000. If you skip that step, RasterToPolygon will create one polygon for each and every different contiguous area of one specific elevation value, so you will get one polygon for 3001, anoter one for 3002 etc.

The select on area after the RasterToPolygon is just to sort out all the small islands. If you do this manually (a one time task) you could just as well open the the feature class in ArcMap and select the area you are interested in, and then export to another feature class.

Try out these tools one at a time inside ArcMap and see what they do for you. Most tools create new datasets derived from the input, so you won't destroy your original data no matter how much you experiment. Just remember to delete all the garbage you create, or you'll soon run out of disk space.
0 Kudos
RyanHollamby
New Contributor
I wanted to follow up on this thread, in case anyone else needs to know how to do this.

Although Niklas methods made complete sense, I could not get them to work. I would guess it was user error though.

I ended up resolving the issue by creating a shapefile from the DEM. Then as suggested from another member went into the advance editing tab, and used the explode tool. With this tool you can select any polygon within the shapefile and press the delete button. It took me about five minutes to delete them all.

Then I went back and clipped the DEM and Imagery with the shapefile, problem solved.

Thanks again for you help Niklas.

Ryan
0 Kudos