Monday 19 September 2016

Finding locations of highest values in raster using ArcGIS Desktop?


Using ArcGIS 10, I have a raster where I would like to find the pixel with the maximum value in the raster and return its location (center of pixel) in decimal degrees. I would like to iterate through this process returning the location of the second highest value of the raster, then third, and so on so that in the end I have a list of N locations that have the highest values in the raster in order.


I imagine that this might be most easily done using a Python script but I'm open to other ideas if there is a better way.



Answer



If you are happy to use R, there is a package called raster. You can read in a raster using the following command:


install.packages('raster')
library(raster)
test <- raster('F:/myraster')


Then, when you go to look at it (by typing test), you can see the following info:


class       : RasterLayer 
dimensions : 494, 427, 210938 (nrow, ncol, ncell)
resolution : 200, 200 (x, y)
extent : 1022155, 1107555, 1220237, 1319037 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs +towgs84=0,0,0
values : F:/myraster
min value : 0
max value : 1


There may be better ways of manipulating the raster, but one way of finding the info you want could be to find the highest value, and get it's matrix location, and then add that to the lower extents.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...