Add an attribute to a polygon shapefile and plot it
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, MATLAB community!
I would like to plot an attribute of a polygon shapefile in MATLAB. The shapefile is a watershed that is divided into smaller units also known as subwatersheds.
Basically, for my analysis, I need to create a new field in the polygon, add data for each of thee subwatersheds, and plot them.
The facecolor of each subwatershed should be representative of the magnitude of the added value (higher values should be darker and lower be lighter or the other way around).
Attached is the piece of code that I wrote sometime back in MATLAB 2015a, which worked fine.
However, when I tried the same code with MATLAB 2019a, the polygon plot comes out with some white patches for few subwatersheds (attached as .jpg). I looked around but could not find the cause of this issue.
It would be great if I could get help from someone who has some experience with such an issue.
Any suggestions are appreciated. You may find the attached shapefile.
UsangShape = shaperead('testShapeFile22.shp');
for i1 = 1:length(UsangShape) % for each subwatershed
storeRandomData (i1,1) = randn(1); % store the value as vector
UsangShape(i1).newAttribute =storeRandomData (i1,1); % add data
end
ymin=floor(min(storeRandomData));
ymax=ceil(max(storeRandomData));
spec = makesymbolspec('Polygon', ...
{'newAttribute', [ymin ymax], 'Facecolor', parula})
mapshow(UsangShape, 'SymbolSpec', spec);
set(gca, 'clim', [ymin ymax],'XtickLabel',[],'YtickLabel',[],'XColor', 'none','YColor','none')
colormap(parula);
colorbar;
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Map Display 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!