Selecting points from a raster that have a 20m height difference within a distance of 100m

05-01-2018 11:57 AM
New Contributor

I have a digital elevation model and  i want  to select  the  maximum and  minimum  values within  a distance  of 100m . I want  to use  numpy array to  raster  function  to  convert  my raster  to an  array . 

(1) From the  array  i want  to create  a search window of  100m x 100m  and  select  a the maximum and  minimm values  in the window

(2) I want  to assign a value of 1  to the maximum values and 2  to the minimum value  if  the  difference between the 2 is greater  tha  20m 

(3) All other values  that are  not the maximum or minimum should be assign to zero 

(4) If the  values  do not  meet the creteria, convert all the  values  to zero 

NB. The  window  should  be non_ overlapping so  as to get a unique  combination of the max a nd min value .

I want  to do this for my project  of selecting  a head of 20m over a distance  of 100m and within 50m of the  river created from a DEM 


0 Kudos
7 Replies
MVP Esteemed Contributor

It will be multistep

  • use block statistics
  • use a circular or square block if you can live with a root 2 discrepency
  • get the range... BUT this will not give you what you want since one cell of a value can influence the range.
  • alternately, get the minority (generally the lowest in the block)
  • then get the majority
  • from the latter two rasters, determine the range and those areas that differ by more than 200 will be your area

I would suggest using FocalStatistics even though the neighborhoods overlap

New Contributor

thank you for your time . I tried block and focal statistics . the problem is i get clustered results. when i want to draw lines between the maximum and minimum points in each grid it becomes more difficult . my goal is to convert the maximum and minimum points in a block to points the draw a polyline between the two points.

0 Kudos
MVP Esteemed Contributor

An image of what you are working with would help.  I don't understand you wanting to draw a line between the max and min, since they are values for a block and not the actual location of where they occur... that is a totally different process

0 Kudos
New Contributor

with reference to the image  above, i want to select my maximum point as the weir and the minimum is the powerhouse. the difference between these two points should be <= 100m. My goal is to select maximum points that intersect with the river in a block(100 x 100). if a maximum point does, then i automatically create a polyline (penstock) from the maximum point to the corresponding minimum point. If i use block and or focal statistics i get clusters of these points. it will be difficult for me to determine whether the maximum point lies withing the river .

0 Kudos
MVP Esteemed Contributor

You need the elevation of the origin point or the destination point.  If you have blocks that indicate the desired elevation difference, your next step is to extract those blocks to find the location of the min and max location.  The problem you would now face is that the min and max could be beside one another.  

Since the weir needs to be located on the river, you might just consider extracting the elevation data using a river polyline and look at the elevation profile in 2D

0 Kudos
Esri Esteemed Contributor

Maybe you want to have a look at Hydrologic analysis sample applications—Help | ArcGIS Desktop . You can determine the streams based on your DEM/DTM and convert the streams to 3D and analyze from which point you have  a drop of more than 20m in less than 100m distance. This would require some scripting, but it is feasible. 

0 Kudos
New Contributor

thank you for the suggestion . the scripting part is the one that i want . so far i have created a fishnet of polygons that intersect the river. i then used zonal statistics to to find the maximum and minimum points within each fishnet polygon. since there might be more than one maximum or minimum point in each fishnet polygon, i then used CentralFeature_stats tool to find the central point. below is the code i wrote. my problem now is the new appended feature class is not populating with values.

import arcpy

# getting inputs from the directory
index = r'C:\Users\PC\Documents\ArcGIS\Default.gdb\Clip_index'
point = r'C:\Users\PC\Documents\ArcGIS\Default.gdb\cell_point'
centre_pnts = r'C:\Users\PC\Documents\ArcGIS\Default.gdb\centre_cells'
all_points = r'C:\Users\PC\Documents\ArcGIS\Default.gdb'
outname = "cnt_pnts"

# allowing overwriting
arcpy.env.overwriteOutput = True

#creating a feature class

#creating an empty point feature
empty = arcpy.CreateFeatureclass_management(all_points,outname,'POINT',point)

# using the search cursor to find the most central point in a grid
with arcpy.da.SearchCursor(index,["PageNumber"]) as index_cur:
    for row in index_cur:
         # starting from PageNumber 20
        if row[0] >= 20:
            arcpy.SelectLayerByAttribute_management('index_lyr', 'ADD_TO_SELECTION', "PageNumber = {}".format(row[0]))

            arcpy.MakeFeatureLayer_management(point, 'point_lyr')
            arcpy.SelectLayerByLocation_management('point_lyr', 'WITHIN', 'index_lyr')
            arcpy.CentralFeature_stats('point_lyr', centre_pnts, 'EUCLIDEAN_DISTANCE')
            arcpy.Append_management(centre_pnts,empty, 'TEST')

thank you all for you help
0 Kudos