Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Color Palette to MapView-Map

I'm trying to change the colours of a map (shapefile data), created by a code similar to this:

mapView(MyData, zcol="Column_Name")

The "Help" page gives two different ways to change colour by using color= or col.regions=. I would like to add a specific palette (YlGn), but haven't found a way to do so. All it says is:

Error in col2rgb(colors, alpha = alpha) : invalid color name 'YlGn'
like image 929
Saalva Avatar asked Jan 01 '23 07:01

Saalva


1 Answers

Here is an example that should clarify the point.

library(mapview)
library(sf)
library(RColorBrewer)

mapview(franconia, zcol = "SHAPE_LEN", col.regions=brewer.pal(9, "YlGn"))

enter image description here

like image 140
Marco Sandri Avatar answered Jan 08 '23 12:01

Marco Sandri