Plotting polygon on geoglobe

8 views (last 30 days)
Mathieu Vinette
Mathieu Vinette on 27 Oct 2021
Answered: Milan Bansal on 29 Apr 2024
How can someone plot a polygon with fill color on a geoglobe plot. Currently, I'm able to plot lines using the following code.
uif = uifigure;
g = geoglobe(uif,'Basemap','satellite','NextPlot','add');
for x=1:length(kmlPoly)
geoplot3(g,kmlPoly(x).Lat,kmlPoly(x).Lon,[],'r');
end
g.Terrain = 'none';
The kmlPoly(attached below) is a Matlab Structure that contains only the Polygons from a .KMZ file that was converterted to a structure. https://www.mathworks.com/matlabcentral/fileexchange/70450-kmz2struct
The above code produces this:
But I'm looking to get something like this: (The image below is from Google Earth)

Answers (1)

Milan Bansal
Milan Bansal on 29 Apr 2024
Hi Mathieu Vinette,
I understand you are able to get the boundary of the polygons on geoglobe, but you wish to get the filled shapes with different colors instead, as shown in the Google Earth image.
To fill the polygons on a geoglobe in MATLAB, it is not possible to directly use a function like fill or geofill because these are not directly compatible with the geoglobe. However, the color information is given in the "kmlPoly" structure for each polygon. Plot the polygons with their respective colors using geoplot3 as shown in the code snippet below:
uif = uifigure;
g = geoglobe(uif,'Basemap','satellite','NextPlot','add');
for x=1:length(kmlPoly)
geoplot3(g,kmlPoly(x).Lat,kmlPoly(x).Lon,[], Color = kmlPoly(x).Color); % Getting the colour from kmlPoly
end
g.Terrain = 'none';
Here is the output of the above code.
Please refer to the following documentation to learn more about geoglobe and geoplot3.
Hope it helps!

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!