Trying to get a basemap to work with geoshow

62 visualizaciones (últimos 30 días)
Justin Bell
Justin Bell el 20 de Mayo de 2022
Editada: Siraj el 3 de Nov. de 2023
Presumably this is pilot error, or perhaps I'm trying to do something that cannot be done.
I'm importaing kml data of lines using the kml2struct function developed by the community (using the mapping toolbox functions didn't seem to work for me - again possible pilot error, it imports the file but somehow does not collect the lat/longs)
I can plot the data using geoshow(theData) but I can't get any basemaps to work. If I plot points using geoscatter I can load a nice background such as "geobasemap streets" but when I try and do any basemap with geoshow i get a pile of errors. Right now I am using readgeotable("usastatehi.shp") to at least get the state borders loaded up but it is not as nice as what I can get doing a geoscatter plot.
I can't seem to find any examples of this so perhaps it cannot be done, but I can't fathom why I can get a nice map when I import points from a google earth file, but not when I import lines.
  2 comentarios
Amit Kallush
Amit Kallush el 20 de Feb. de 2023
Hi, I'm having the same problem, unable to load any basemap to a geoshow figure.
Did you figured it out maybe?
Justin Bell
Justin Bell el 20 de Feb. de 2023
I never got support on this, and at the time I did not find an answer anywhere online. I still have no solution, and it may not be possible for whatever reason.
For my specifc needs I ended up using geoscatter since that worked and then pulled the graphic into powerpoint and drew all the lines where they needed to go manually for one figure, and then told my project team that graphic gets cut out of the workflow now because matlab cant support it. I would love to see a workaround for this if you find one.
best of luck

Iniciar sesión para comentar.

Respuesta aceptada

Siraj el 1 de Nov. de 2023
Editada: Siraj el 3 de Nov. de 2023
It seems that you are facing difficulties while using the “geoshow” function in MATLAB to plot data. You mentioned that you are unable to load any basemaps when using “geoshow”. However, you are able to successfully load a background using the "geobasemap streets" when using the “geoscatter” function.
As per my knowledge, this is because the basemaps are pre-projected and tiled in the "Web Mercator" projected coordinate system which is the type of map projection built into “geoaxes” and “webmap”.
On the other hand, maps created with “axesm”, “worldmap”, or “usamap” (which can be used with the “geoshow” and “mapshow” functions) allow several dozen different types of projection, most of which are incompatible with the basemap tiles.
Starting from R2022a, you can make use of the "readgeotable" function to import your data into a geospatial table. Subsequently, you can use the "geoplot" function to visualize this data on a geographic axes. To learn more about the "readgeotable" function and geospatial tables, you can refer to the following links.
Refer to the provided code for a more comprehensive understanding.
% Download and save the "storms.geojson" file from the specified URL.
% Read the contents of the "storms.geojson" file into a geospatial table (GT).
GT = readgeotable("storms.geojson");
% Create a geographic plot to visualize the data in the geospatial table.
% Set the basemap to "streets" for better context in the geographic plot.
You can also consider using alternative functions such as "geobubble" or "geoplot" as a workaround. The following code snippet can provide you with a better understanding:
% Example using latitude and longitude coordinates:
lat = [28.6139, 28.6139, 28.7041, 28.6139];
lon = [77.2090, 77.2290, 77.1025, 77.2090];
% Use geoplot to display the geographic data
geoplot(lat, lon);
geobubble(lat,lon, "Basemap","streets-dark");
Refer to the following links to learn more about the above functions.
Another option you can explore is using the "geoaxes" function in MATLAB. This function allows you to create geographic axes and modify the associated basemap. For more details and examples, you can refer to the following link:
Hope this helps.
  1 comentario
Justin Bell
Justin Bell el 1 de Nov. de 2023
Thanks for the clarification on the projection type, it makes sense now that you've explained it. I'll read up on those links!

Iniciar sesión para comentar.

Más respuestas (0)


Más información sobre Geographic Plots en Help Center y File Exchange.




Community Treasure Hunt

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

Start Hunting!

Translated by