1

I have a shapefile:

enter image description here

I would like to colour each polygon according to the value it holds. I can do this using the following code:

shapefile$colour = 
  ifelse(shapefile$Count >= 0 & shapefile$Count <= 40,
         "blue",
         "red")

However, what I would like to do is to decide on my colour scheme in a data frame and then merge this onto the shapefile:

shapefile = merge(shapefile, dataframe, by = "Polygon", all.x = TRUE)

When I do this, I do not get the colours I have specified, despite them reading correctly when I check shapefile@data.

Could anyone help me understand why this happens and also if there is any way around it? Thank you!

AJGL
  • 303
  • 3
  • 9
  • 1
    Including a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) in your question will increase your chances of getting an answer. – Samuel Nov 22 '17 at 15:56
  • I found the [GIS Stackexchange](https://gis.stackexchange.com/) very helpful. You might consider posting there. – Michael Bird Nov 22 '17 at 16:11
  • Thank you. I have re-worded the question here: – AJGL Nov 24 '17 at 16:23
  • https://gis.stackexchange.com/questions/262723/why-do-colours-merged-onto-a-shapefile-in-base-r-display-incorrectly – AJGL Nov 24 '17 at 16:23

0 Answers0