79491029

Date: 2025-03-07 01:16:19
Score: 1
Natty:
Report link

Thank you L Tyrone, that was very helpful! I modified your example to something that was easier for me, a total beginner, to understand and was successful in making my map.

This is what I used:

#load libraries
library(sf)
library(tmap)
library(dplyr)

#read in shape file
YGS_GLGY <- st_read("Yukon_Bedrock_Geology_Complete.shp/Bedrock_Geology.shp/Bedrock_Geology.shp")

#Colour the polygons using the RGB values provided under the columns RED, GREEN, BLUE.

#the RGB colours need to be scaled from (0 - 255) to (0 - 1)
YGS_GLGY <- YGS_GLGY |>
  mutate(R = RED / 255,
         G = GREEN / 255,
         B = BLUE / 255)

#then, they need to be converted to one column of hex values
YGS_GLGY <- YGS_GLGY |>
  mutate(HEX = rgb(R, G, B))

#then the coloured polygons can be plotted as a map
tm_shape(YGS_GLGY) +
  tm_polygons(fill = "HEX") +
  tm_borders() +
  tm_scalebar(position = c(0.01, 0.035)) +
  tm_compass(size = 1.5, position = c(0.05, 0.95))
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Kirsten Rasmussen