How can I overlay a shapefile onto a geoscatter plot?

15 次查看(过去 30 天)
I am plotting radiocarbon data for the U.S. state of Ohio using the geoscatter() function:
geoscatter(radio.Latitude,radio.Longitude,250,'.r') % Lat/Lon coordinates are from a table of radiocarbon data
geolimits([38 42.5],[-84 -81]) % [degrees N],[degrees E] => limits axes to the Ohio region
geobasemap colorterrain
The above code works perfectly. Next, I have a shape file that I want to overlay on top of my geoscatter plot. I have already tried the following:
info = shapeinfo('filename.shp'); % extract information from shapefile
crs = info.CoordinateReferenceSystem % verifies the shapefile uses latitude and longitude coordinates
S = shaperead('filename.shp','UseGeoCoords',true); % read the shapefile using geocoordinates
% Add shapefile to geoscatter plot
hold on
geoshow(S)
hold off
However, I get several errors:
  • Error using hggroup
  • Group cannot be a child of Geographic Axes
  • Error in symbolizeMapVectors>plotMapFeature (line 139)
  • hg = hggroup('Parent', get(h,'Parent'));
  • Error in symbolizeMapVectors (line 119)
  • hg = plotMapFeature(S(k), hg, props, plotfcn);
  • Error in geostructshow (line 145)
  • h = symbolizeMapVectors(S, symspec, fcn, defaultProps, otherProps);
  • Error in geoshow (line 242)
  • h = showFcn(varargin{:});
What do I need to change in order to fix this? Or is it not possible to overlay a shapefile on a geoscatter plot?
Thank you.

采纳的回答

millercommamatt
millercommamatt 2021-11-3
Plotting shapefiles on a geographic axis isn't always the best experience. You'll note that geoshow is intended for use with a standard or map axes. But, we can still make things work.
The resulting figure becomes slow to respond to mouse interactions because there are 537 seperate geoplot objects and children to the geoaxes, but this works.
ls = shaperead('landareas.shp');
fh=figure();
ah = geoaxes(fh);
hold(ah,'on');
for ii = 1:length(ls)
geoplot(ah,ls(ii).Y,ls(ii).X)
end
  2 个评论
Austin M. Weber
Austin M. Weber 2021-11-4
Thank you for the reply. Unfortunately, I still receive an error:
"Error using geoplot (line 85). Expected lat to be an array with all of the values <= 90."
millercommamatt
millercommamatt 2021-11-4
I'd have to see the code to comment on the error. It suggests that you have Latitude values greater than 90. Check you data to make sure it's what it should be.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by