изменить цвет NA на карте почтового индекса - PullRequest
0 голосов
/ 16 сентября 2018

Я создал карту на немецком почтовом индексе со своими данными.Мои данные не содержат все почтовые индексы, поэтому у меня есть пропущенные значения.Недостающие значения отображаются черным на карте;Я хочу, чтобы они были белыми.Как я могу это изменить?

ger_plz <- readOGR(dsn = ".", layer = "plz-2stellig")

gpclibPermit()
#convert the raw data to a data.frame as ggplot works on data.frames
ger_plz@data$id <- rownames(ger_plz@data)
ger_plz.point <- fortify(ger_plz, region="id")
ger_plz.df <- inner_join(ger_plz.point,ger_plz@data, by="id")

head(ger_plz.df)
ggplot(ger_plz.df, aes(long, lat, group=group )) + geom_polygon()

#data file
Ers <- table(data.plz$plz)
df<- as.data.frame(Ers)

# variable name 'region' is needed for choroplethr
ger_plz.df$region <- ger_plz.df$plz
head(ger_plz.df)

#subclass choroplethr to make a class for your my need
GERPLZChoropleth <- R6Class("GERPLZChoropleth",
                            inherit = choroplethr:::Choropleth,
                            public = list(
                              initialize = function(user.df) {
                                super$initialize(ger_plz.df, user.df)
                              }
                            )
)
#choropleth needs these two columnames - 'region' and 'value'
colnames(df) = c("region", "value")

#instantiate new class with data
c <- GERPLZChoropleth$new(df)

#plot the data
c$ggplot_polygon = geom_polygon(aes(fill = value), color = NA)
c$title = "Erstsemester Landau 2017"
c$legend= "Heimatort"
c$set_num_colors(9)
c$render()

picture of my map

...