You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have just noticed a potential bug, when show_landscape() is used for a raster with classes defined by ratify(). Please see the reproducible example below:
Lets first look at the default map directly, without classification trough ratify():
Now we classify the three land uses with different names, and execute show_landscape() with the default (wrong!) color scale:
# Ratify raster and define 3 example class names for landuse 1, 2 and 3:
ls <- raster::ratify(landscapetools::classified_landscape)
levels(ls)[[1]] = cbind(levels(ls)[[1]],
c("Land Use 1" = "Bare (lu1)", "Land Use 2" = "Rainforest (lu2)", "Land Use 3" = "Agriculture (lu3)"))
# Show landscape with default (wrong!) fill scale:
show_landscape(ls, discrete=TRUE)
This produces the following map:
you can already see, that the legend order is the same if you look at the numbers in the brackets, which were the original land use numbers, but the coloring of the patches changed on the map.
Now we overwrite the default fill scale from show_landscape():
# Show landscape with overwritten (correct!) fill scale:
show_landscape(ls, discrete=TRUE) +
scale_fill_viridis_d()
This produces the following map which has the correct legend order:
I assume, the error is due to the order of factors, where the ratify levels are defined.
Cheers, nldoc
The text was updated successfully, but these errors were encountered:
I have just noticed a potential bug, when
show_landscape()
is used for a raster with classes defined byratify()
. Please see the reproducible example below:Lets first look at the default map directly, without classification trough
ratify()
:Now we classify the three land uses with different names, and execute show_landscape() with the default (wrong!) color scale:
This produces the following map:
you can already see, that the legend order is the same if you look at the numbers in the brackets, which were the original land use numbers, but the coloring of the patches changed on the map.
Now we overwrite the default fill scale from
show_landscape()
:This produces the following map which has the correct legend order:
I assume, the error is due to the order of factors, where the ratify levels are defined.
Cheers, nldoc
The text was updated successfully, but these errors were encountered: