Searching for the nearest point on a grid using dsearchn
I am trying to compare field data with classified sattellite imagery.
What I am aiming for is to find the nearest pixel in the sattellite image to the location of the field data.
The coordinates of the pixels are in X & Y represented by blue circles below, spacing is 30m x 30m.
The coordinates of the field data is in TransectDataStats.Easting & .Northing represented by "x’s" below.
The dots are the "closest point" as determined by the matlab function dsearchn.
Most of the results look ok but there are some werid ones highlighted in red below that don’t seem right. Some there appears to be a closer point than the one selected and one that doesn’t seem to have a field point anywhere near it.
Questions
Am I using this function correctly?
Can anyone explain why the oddball "nearest points"?
What could be done to fix this?
Is there an alternative function or method to acheive the result I am aiming for?
NearestPoint = dsearchn([X(:),Y(:)],[TransectDataStats.Easting,TransectDataStats.Northing])
figure
plot(X(:),Y(:),’o’)
hold on
plot(X(NearestPoint),Y(NearestPoint),’.’)
plot(TransectDataStats.Easting,TransectDataStats.Northing,’x’)
axis equal
size(X)
ans =
2895 921
size(TransectDataStats.Easting)
ans =
654 1I am trying to compare field data with classified sattellite imagery.
What I am aiming for is to find the nearest pixel in the sattellite image to the location of the field data.
The coordinates of the pixels are in X & Y represented by blue circles below, spacing is 30m x 30m.
The coordinates of the field data is in TransectDataStats.Easting & .Northing represented by "x’s" below.
The dots are the "closest point" as determined by the matlab function dsearchn.
Most of the results look ok but there are some werid ones highlighted in red below that don’t seem right. Some there appears to be a closer point than the one selected and one that doesn’t seem to have a field point anywhere near it.
Questions
Am I using this function correctly?
Can anyone explain why the oddball "nearest points"?
What could be done to fix this?
Is there an alternative function or method to acheive the result I am aiming for?
NearestPoint = dsearchn([X(:),Y(:)],[TransectDataStats.Easting,TransectDataStats.Northing])
figure
plot(X(:),Y(:),’o’)
hold on
plot(X(NearestPoint),Y(NearestPoint),’.’)
plot(TransectDataStats.Easting,TransectDataStats.Northing,’x’)
axis equal
size(X)
ans =
2895 921
size(TransectDataStats.Easting)
ans =
654 1 I am trying to compare field data with classified sattellite imagery.
What I am aiming for is to find the nearest pixel in the sattellite image to the location of the field data.
The coordinates of the pixels are in X & Y represented by blue circles below, spacing is 30m x 30m.
The coordinates of the field data is in TransectDataStats.Easting & .Northing represented by "x’s" below.
The dots are the "closest point" as determined by the matlab function dsearchn.
Most of the results look ok but there are some werid ones highlighted in red below that don’t seem right. Some there appears to be a closer point than the one selected and one that doesn’t seem to have a field point anywhere near it.
Questions
Am I using this function correctly?
Can anyone explain why the oddball "nearest points"?
What could be done to fix this?
Is there an alternative function or method to acheive the result I am aiming for?
NearestPoint = dsearchn([X(:),Y(:)],[TransectDataStats.Easting,TransectDataStats.Northing])
figure
plot(X(:),Y(:),’o’)
hold on
plot(X(NearestPoint),Y(NearestPoint),’.’)
plot(TransectDataStats.Easting,TransectDataStats.Northing,’x’)
axis equal
size(X)
ans =
2895 921
size(TransectDataStats.Easting)
ans =
654 1 dsearchn, satellite imagery, closest pixel, image processing MATLAB Answers — New Questions