AnsweredAssumed Answered

Need python equivalent to Avenue’s  “ReturnContour”

Question asked by rastrauch Champion on Jul 7, 2015
Latest reply on Jul 8, 2015 by rastrauch

I’m working on updating one of my old Avenue scripts.


Short description (of this particular problem in a longer process): given a set of random points within a study area, I need to create a contour at the elevation value of the random point, and using that as the center, create a transect on that contour at a given length, 50% in each direction….adjusting if necessary to keep within the study area.  (and there are other factors I don’t need to get into right now).


I’ve been able to grab the xy from a given point, and retrieve the value from the raster. The problem I am having right now is I can’t find an arcpy replacement for  ReturnContour (as shown in this line)


theFullContour = ElevTheme.GetGrid.ReturnContour(p, z, Prj.MakeNull)


My guess is it a NumPy solution (Dan Patterson maybe??), but I’m not sure what to search for.  Once I get the (poly)line, I should be ok with geometries.)


Does anyone have a simple way in python to return a single contour given an x/y/z and a raster?  Anyone in Geoprocessing or Imagery and Rasters  ??  Please, python solution C#/arcobjects.




EDIT:  meant to include a snippet of test code for getting the point, in case anyone wants to test on their own data.  I'm grabbing point 7 of 2000 because I know it will return a good contour (some will not....too flat, which is handled elsewhere)

myPoints = r"C:\ADFG.gdb\myRandomPts2"
theDEM = r"C:\ADFG.gdb\DEM20aExtent"
cnt = 1
for row in arcpy.da.SearchCursor(myPoints, ["SHAPE@XY"]):
    if cnt == 7:
        x,y = row[0]      
        print("{}, {}, {}".format(cnt, x, y))
    cnt = cnt + 1
#x, y = 377906.9379, 1538997.6698
print("{}, {}".format(x, y))
ptLoc = str(x) + ' ' + str(y)

z1 = arcpy.GetCellValue_management("DEM20aExtent",ptLoc)


Message was edited by: Rebecca Strauch  added code snippet