I would like to write a cycle which takes a current pixel, look at the surrounding pixels, choose the pixel with max/min value and skip to that pixel...and so on.

Is there in arcpy such a function which can work with pixel's neighborhood?

  • Do you want a raster that only has values in those cells? Focal Statistics can do something very similar, but it will calculate a value for each cell, it doesn't skip around. It also requires the Spatial Analyst extension. – Evil Genius Jan 2 '14 at 12:06
  • Focal Statistics doesn't help me. It's similar, but I need to know which values are around my current pixel. I want to enter specific pixel from my raster and get something like: left pixel value is 10, right pixel value is 12...and so on. Or something similar...Any idea? – kaisers Jan 2 '14 at 12:23

What about using Get Cell Value with offsets equal to the cell size as location_point? E.g. if the coordinates of the center of your pixel of interest are (x, y) and the cell size of your raster is 10, you run the tool for (x - 10, y), (x + 10, y), (x, y - 10) and so on, add every result to a list and select the min or max value from the list.

  • Good idea, I will try that, thanks. Maybe one more thing: If I have the exact coordinates of a point (for example obtained by a mouse click or from some table), how do I get the corresponding pixel and its center? – kaisers Jan 2 '14 at 22:53
  • Get Cell Value doesn't need the pixel center, it uses a pair of coordinates (location_point parameter) and will retrieve the cell value of the pixel overlapping the coordinates. Actually the method I proposed will work as long as the coordinates are located inside the pixel you're interested in. – GISGe Jan 3 '14 at 6:39
  • Ok, I understand. But still, is there a way to find out the center of pixel inside which lies my point? I need that, because my idea is take random point and from that point start the iteration. And if the point won't be exactely in the center of pixel, this method of (x - 10, y), (x + 10, y), (x, y - 10) and so on won't be accurate enough.. If you know what I mean? – kaisers Jan 3 '14 at 9:29
  • Well since pixel values are the same all over the pixel, it doesn't matter whether you're in the center or not. And if you use the cell size as offset, you'll always get the value of the pixel next to your pixel of interest. I'm sorry if I've confused you by talking about pixel center in my first post, I didn't know how you obtained the coordinates of the pixel of interest so I assumed (wrongly) you knew the pixel center coords. I don't know any method to get the pixel's center coordinates. – GISGe Jan 3 '14 at 9:46

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.