How can I overlay a shapefile onto a geoscatter plot?
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Geographic Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!