B = changem(A,new)
replaces all occurrences of 0 in array A with the
specified scalar new. This function is useful for replacing values in
classification grids.
B = changem(A,new,old)
replaces all occurrences of old with new.
Read a land cover classification of Oahu, Hawaii [1] as a matrix, a map cells reference object, and a colormap. The elements of the matrix index into the colormap.
[A,R,cmap] = readgeoraster("oahu_landcover.img");
Deciduous forest, evergreen forest, and mixed forest are indicated by the values 9, 10, and 11 in the matrix, respectively. Create a matrix that uses the same color for all forests by replacing occurrences of 9 and 10 with 11.
new = [11 11];
old = [9 10];
B = changem(A,new,old);
Display the original land cover classification on a map. Set up the map using the projected coordinate reference system (CRS) that is stored in the reference object. Prepare to display the data with the geoimage function by converting the indexed image to an RGB image.
figure
newmap(R.ProjectedCRS)
A_RGB = ind2rgb(A,cmap);
geoimage(A_RGB,R)
title("Land Cover Classification with Three Forest Types")
Display the updated land cover classification on a similar map.
figure
newmap(R.ProjectedCRS)
B_RGB = ind2rgb(B,cmap);
geoimage(B_RGB,R)
title("Land Cover Classification with One Forest Type")
[1] The data used in this example is courtesy of the National Oceanic and Atmospheric Administration (NOAA).
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.