Hello,
I have Grid shape file and Point shape file. In the point Shape file there is the "Elevation value". I had updated the Gridno to the point shape file using Spatial join and named as "PointwithGridNo". I want to get the maximum and minimum elevation values of every GridNo in the "PointwithGridNo" using Python script. Can any one suggest me.
What have you got so far as a script? Can you do it manually? Because if you know how, then it can be scripted
I haven't tested this, but I assume that you could use something like this (although some sample data would be helpful):
def main(): import arcpy # include path to PointwithGridNo fc = r"C:\Folder\SubFolder\yourFGDB.gdb\PointwithGridNo" # change names of fields according to your data fld_gridno = "GridNo" fld_elevation = "elevation" fld_min = "min_elevation" # assuming this field already exists fld_max = "max_elevation" # assuming this field already exists # create dictionary with min and max values per GridNo flds = (fld_gridno, fld_elevation) dct_minmax = {} with arcpy.da.SearchCursor(fc, flds) as curs: for row in curs: gridno = row[0] elevation = row[1] if gridno in dct_minmax: min_elev = dct_minmax[gridno]["min"] if dct_minmax[gridno]["min"] < elevation else elevation max_elev = dct_minmax[gridno]["max"] if dct_minmax[gridno]["max"] > elevation else elevation dct_minmax[gridno] = {"min": min_elev, "max": max_elev} else: dct_minmax[gridno] = {"min": elevation, "max": elevation} # use update cursor to update min and max elevation flds = (fld_gridno, fld_min, fld_max) with arcpy.da.SearchCursor(fc, flds) as curs: for row in curs: gridno = row[0] if gridno in dct_minmax: row[1] = dct_minmax[gridno]["min"] row[2] = dct_minmax[gridno]["max"] curs.updateRow(row) if __name__ == '__main__': main()
Raj: the Summary Statistics tool should do the trick. There's a python example in the help.