I have combined two layers to create a shapefile which I am colouring using the Choropleth function in GISTools. The problem I am having is that despite having no other problems with my code including with the actual mapping of the choropleth itself, nothing I can do, using choro.legend, actually appears. I have checked I am plotting in the right pace using locator().
My code is below. I have also attached my data and link to shapefile and attached my data. Many thanks in advance. Henry https://borders.ukdataservice.ac.uk/ukborders/easy_download/prebuilt/shape/infuse_dist_lyr_2011.zip require(rgdal) require(sp) library(plyr) library(dplyr) library(RColorBrewer) MyDataFile2 <- read.csv("reduced1.csv") class(MyDataFile2) coordinates(MyDataFile2)<-~X+Y class(MyDataFile2) writeOGR(MyDataFile2, "Folder", "File9", driver = "ESRI Shapefile") Redefined2 <- readOGR(dsn="Folder", layer = "File9") proj4string(Redefined2) <- CRS("+init=epsg:4326") # WGS 84 MyMap <-readOGR(".","infuse_dist_lyr_2011") proj4string(MyMap) MyMapb <- spTransform(MyMap, proj4string(Redefined2)) MyMapb@data <- mutate(MyMapb@data, id_poly = as.numeric(rownames(MyMapb@data))) Redefined2@data <- mutate(Redefined2@data, id_la = as.numeric(rownames(Redefined2@data))) New <- over(Redefined2, MyMapb) New <- mutate(New, id_la = as.numeric(rownames(New))) New <- left_join(Redefined2@data, New, by = c("id_la" = "id_la")) New2 <- New %>% group_by(id_poly) %>% dplyr::summarise(avgBrit = mean(Brtshns), SumBrit = sum(Brtshns), nBrit = n()) %>% arrange(id_poly) MyMapb@data <- left_join(MyMapb@data, New2, by = c("id_poly" = "id_poly")) View(MyMapb) shape2 <- MyMapb[!is.na(MyMapb@data$avgBrit),] myshading = auto.shading(shape2$avgBrit, n=7, cols=brewer.pal(7, "Spectral")) choropleth(shape2, shape2$avgBrit,shading=myshading) choro.legend(48.4,-5.79, myshading,fmt="%4.1f",cex=0.8) ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.