Hi Sierra,
According to my understanding you want to find the union of shapes of type "geopolyshape". Currently, we cannot find the union for "geopolyshape" type directly. Instead of using "geopolyshape", you can try using the "geoshape" type with the "polybool" function for union. Following is a sample code to perform the union of two "geoshape" type variables:
geoShape1 = geoshape([dep_lat(i,1),dep_lat(i,2),dep_lat(i,3),dep_lat(i,4)],[dep_lon(i,1),dep_lon(i,2),dep_lon(i,3),dep_lon(i,4)]);
geoShape2 = geoshape([dep_lat(i+1,1), dep_lat(i+1,2), dep_lat(i+1,3) ,dep_lat(i+1,4)],[dep_lon(i+1,1),dep_lon(i+1,2), dep_lon(i+1,3) ,dep_lon(i+1,4)]);
[lat, lon] = polybool('union', geoShape1.Latitude, geoShape1.Longitude, geoShape2.Latitude, geoShape2.Longitude);
% Convert the resulting latitude and longitude arrays back to geopolyshape object
polyout = geopolyshape(lat, lon);
geoplot(polyout);
You can also use "polyshape" instead of "geoshape" to directly use the "union" function like this:
geoShape1 = polyshape([dep_lat(i,1),dep_lat(i,2),dep_lat(i,3),dep_lat(i,4)],[dep_lon(i,1),dep_lon(i,2),dep_lon(i,3),dep_lon(i,4)]);
geoShape2 = polyshape([dep_lat(i+1,1), dep_lat(i+1,2), dep_lat(i+1,3) ,dep_lat(i+1,4)],[dep_lon(i+1,1),dep_lon(i+1,2), dep_lon(i+1,3) ,dep_lon(i+1,4)]);
ans = union(geoShape1, geoShape2);
geopoly = geopolyshape(ans.Vertices(:, 1), ans.Vertices(:, 2));
geoplot(geopoly);
You can read more about these functions here:
- polybool: https://www.mathworks.com/help/map/ref/polybool.html
- polyshape: https://www.mathworks.com/help/matlab/ref/polyshape.html
- geoshape: https://www.mathworks.com/help/map/ref/geoshape.html
Hope this helps!