How to find the immediate neighbors of a point in a map?
Show older comments
I'm trying to evaluate the effect of deforestation in a region of the Brazilian Amazon. And to do this, I have a matrix with known latitude and longitude points. Each of these represents a certain area of the terrain, and have information about that area, as deforestation level and type of forest.
What I need to know is how many of the 8 immediate neighbors of each point are deforested, (see image). My point is, although I know the lat/lon of each point, I don't know an efficient way of how to find these neighbors. This matrix has more than 1 million points, and it can be really time consuming.

Accepted Answer
More Answers (1)
Image Analyst
on 16 Jun 2015
0 votes
If you have the Statistics Toolbox you might be able to use pdist(). It gives the distance of every point to every other point. If each point is a blue circle in your image, then it looks like there are only a few thousand points and so pdist() shouldn't take that long. For each row (each point) you can sort the row in ascending order with sort() to find the other points that are closest.
Categories
Find more on Map Display in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!