How to sort X and Y vectors to achieve a correct "fill"?
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
I exteacted a shapefile form qGIS, and I am trying to plot many polygons in Matlab. The issue is that, for some polygons, the order of the coordinate vectors (X and Y) are not ordered according to the reall shape (which is the geolofical mapping), so some polygoons are crossed by lines which should not be there (see attached figure).
The interesting thing is that qGIS itself can handle it (there,. I do not see any crossing lines). What would be a solution for that issue in Matlab?
Thanks,
Ron
1 个评论
Steven Lord
2024-6-10
Suppose I had five points of data.
x = [1 3 3 2 1 1];
y = [1 1 3 2 3 1];
plot(x, y, 'o')
axis([0 4 0 4])
If I just had those five points, no connectivity data, which is "the real shape" for those points? Is it this?
figure
plot(x, y, 'o-')
axis([0 4 0 4])
Or how about this?
figure
plot(x([1 4 2 3 5 6]), y([1 4 2 3 5 6]), 'o-')
axis([0 4 0 4])
Or:
figure
plot(x([1 2 4 3 5 6]), y([1 2 4 3 5 6]), 'o-')
axis([0 4 0 4])
Or even this zero-area shape (which admittedly likely isn't the right answer for a set of geospatial data, though if you look at how some political subdivisions are gerrymandered in the United States you can't rule it out entirely.)
figure
plot(x([1 4 2 4 3 4 5 4 6]), y([1 4 2 4 3 4 5 4 6]), 'o-')
axis([0 4 0 4])
How did you import the data from the file? Is there additional information stored in the file about the connectivity of those points that you aren't using but should be using to avoid this issue?
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!