I am using a 50mx50m grid irregular shaped DEM file.

I have to work on the boundary conditions.

How do i extract the cell locations ( in x,y coordinate ) along the boundary edge and consequently find the elevation of the respective boundary cells.

I am using ArcGIS 9.3 for my work.


This question asks for two things: (1) identify the boundary cells and (2) "find" their elevations. Although "find" could be interpreted in many ways (do you want an output table of elevations? A DEM containing only those cells? etc.), doing it is straightforward once you have solved (1), especially if the boundary cells have been represented as an indicator grid: this is a grid that has one kind of value at the desired cells and another value at all other cells. Depending on the follow-on analysis, a 1-0 indicator or a 1-NoData indicator usually work best (and either is converted into the other using SetNull and IsNull).

The problem is thereby reduced to efficiently computing an indicator grid for the boundary cells. If we characterize a boundary cell as one that is adjacent to at least one NoData cell (where "NoData" includes hypothetical cells that would lie beyond the edges of the grid itself), then the solution evidently requires a "focal" or neighborhood operation. One way is to turn the DEM itself into a 1-0 indicator; this can be done with Not and IsNull. Then a focal sum of this indicator will be less than the neighborhood size exactly where there are zeros in the neighborhood: these would be all boundary cells and all original NoData cells.

To summarize, an efficient raster-based workflow to create an indicator grid of all boundary cells starting from a DEM is given by this pseudocode:

i = Not(IsNull('DEM'))          # Store a DEM indicator in temporary grid `i`
n = FocalSum('i', ...) < x      # Store a near-boundary indicator in temporary grid `n`
'i' & `n`                       # The desired boundary indicator

The x represents the neighborhood size; for instance, when using a 3 by 3 neighborhood, x would be 9. The "..." in FocalMean indicates arguments needed to specify the neighborhood: different neighborhoods correspond to different definitions of what it means to be on the "boundary". See the help page for the syntactical details. The & operator is Spatial Analyst's "Boolean And" which will be true exactly when both its arguments are true: this picks out those cells that are part of the DEM (indicated by grid i) and have NoData values in their neighborhoods (indicated by grid n).

As an example, here is a corner of a much larger DEM, shown hillshaded:

DEM insert

Its indicator i is constantly 1 where the DEM has values, shown here as gray:

DEM indicator

The focal sum of i, using a 3 by 3 neighborhood, can have values between 0 and 9, shown on this temperature-like map (graduating from red for 0 through greens and blues and finally becoming transparent for the maximum value of 9, revealing the gray from i itself):

DEM border

You can see that all the action is around the perimeter, as it should be. Overlaying those cells that are less than 9 with the indicator i shows the cells that are part of the DEM and on its border, exhibited here in red overlaid on the original DEM:

Boundary cell indicator

(Notice that the border in this case includes an internal cell that was missing a value: it's near the center bottom.)

This procedure involves just five grid operations (Not, IsNull, FocalSum, <, and &), all of which are very fast to execute. Thus, even if the ultimate intention is to output a table of values or a point shapefile or some other non-raster representation of the boundary cell values, it will be easier and computationally much more efficient to get to this point using raster operations before converting to another representation.

  • 1
    As always a superior way of doing things! I've worked through your example and its great! Definitely learnt some clever use of rasters. All I can add is that "<" is the Less Than tool and "&" is the Boolean And tool.
    – Hornbydd
    Feb 22 '13 at 17:42
  1. I would convert the raster to a point dataset (Search for the raster to Point tool).
  2. Add a X and Y field type double
  3. Run calculate geometry tool extracting the X and Y of the point
  4. As you have 1 grid its probably just easy to select the boundary points and export the selection?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.