Trying to get a basemap to work with geoshow
49 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Amit Kallush
le 20 Fév 2023
Hi, I'm having the same problem, unable to load any basemap to a geoshow figure.
Did you figured it out maybe?
Thanks,
Amit
Réponse acceptée
Siraj
le 1 Nov 2023
Modifié(e) : Siraj
le 3 Nov 2023
Hi!
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.
websave("storms.geojson","https://www.spc.noaa.gov/products/outlook/day1otlk_cat.lyr.geojson");
% 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.
geoplot(GT)
% Set the basemap to "streets" for better context in the geographic plot.
geobasemap("streets")
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);
geobasemap("streets-light");
figure;
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Geographic Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!