Plotting polygon on geoglobe

9 次查看(过去 30 天)
Mathieu Vinette
Mathieu Vinette 2021-10-27
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)

回答(1 个)

Milan Bansal
Milan Bansal 2024-4-29
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!

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by