How can I overlay a shapefile onto a geoscatter plot?
12 ビュー (過去 30 日間)
古いコメントを表示
Austin M. Weber
2021 年 11 月 2 日
コメント済み: millercommamatt
2021 年 11 月 4 日
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.
0 件のコメント
採用された回答
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 件のコメント
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 Center および File Exchange で Geographic Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!