Identifying Intersecting shapefiles from d-km radius buffer of latitude longitude (Mapping toolbox)

15 次查看(过去 30 天)
Hello
I have a set of latitude and longitude information. Say, lat = -29.97 and lon = 30.95. I wish to find a d degree, say 0.2 deg. buffer radius around the city location. Then I wish to identify if this buffer intersect with a land-use and landcover shapefile. I have a shapefile with 100+ polygons, so I tried to loop over.
To identify the buffer radius, I did the following:
Lat = -29.97; Lon = 30.95;bufferDistance = 0.2;
[bufLat, bufLon] = bufferm(City_Lat, City_Lon, bufferDistance, 'outPlusInterior');
S = shaperead('Shapefile.shp');
for jdx = 1:size(S,1)
Xbound = S(jdx,1).X;
Ybound = S(jdx,1).Y;
[Intersected_Lon,Intersected_Lat] = polybool('intersection',bufLon,bufLat,Ybound,Xbound);
end
However, I am getting warning message as: "(X1,Y1) contains no external contours. Function POLYBOOL assumes that external contours have clockwise-ordered vertices, and all contours in (X1,Y1) have counterclockwise-ordered vertices. Use POLY2CW to reverse the vertex order if necessary."
Unrecognized function or variable 'intersectLon'.
Is there any other way to solve this problem? For me the function geobuffer is not working.

回答(1 个)

Ayush
Ayush about 3 hours 前
Hi Poulomi,
I understand you’re running into issues with "polybool," especially the warning about vertex order. The polybool function requires that external polygon contours are defined in a clockwise order.
You may refer to the following documentation to know more about its input format:
To fix this, you can use the "poly2cw" function to reorder your polygon vertices to clockwise order before using "polybool."
You can refer the following documentation to understand about the "poly2cw" function:
Please note that the "polybool" function is not recommended in latest MATLAB documentations. You can use a shape object and the "intersect", "union", "subtract" or "xor" function, instead
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by