Trying to get a basemap to work with geoshow

56 ビュー (過去 30 日間)
Justin Bell
Justin Bell 2022 年 5 月 20 日
編集済み: Siraj 2023 年 11 月 3 日
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 件のコメント
Amit Kallush
Amit Kallush 2023 年 2 月 20 日
Hi, I'm having the same problem, unable to load any basemap to a geoshow figure.
Did you figured it out maybe?
Thanks,
Amit
Justin Bell
Justin Bell 2023 年 2 月 20 日
Amit,
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

サインインしてコメントする。

採用された回答

Siraj
Siraj 2023 年 11 月 1 日
編集済み: Siraj 2023 年 11 月 3 日
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.
  1 件のコメント
Justin Bell
Justin Bell 2023 年 11 月 1 日
Thanks for the clarification on the projection type, it makes sense now that you've explained it. I'll read up on those links!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by