0

I'm looking for a current map of Sierra Leone provinces (admin 1 level). One province split in 2017, making a total of 5, but I can only find files with 4 provinces.

I've checked humdata, DIVA-GIS, and GADM, and they're all out-of-date . As far as I can tell, there isn't a way to have only admin borders on the OpenStreetMap/Geofabrik data set.

Alternately, is there any workaround? I don't need much, just the polygons for the provinces. This is for use in a scientific manuscript. Ultimately, I want to import it into R and add data to it. Thanks!

1 Answer 1

0

Let's try to find the boundaries within OSM data :).

library(osmdata)

bbox <- matrix(data = c(6.9, -14, 10, -10), nrow = 2, ncol = 2)

boundaries <- opq(bbox, timeout = 240) |>
  add_osm_feature (key = "boundary", value = "administrative") |>
  osmdata_sf()

boundary=administrative is the key to look for. You can add another condition here like admin_level=4 as main provinces are on level 4, however we will use other level for the whole country as well.

sl <- boundaries$osm_multipolygons |>
  subset(admin_level == 2 & name == "Sierra Leone") |>
  subset(select = c(osm_id, name))

sl |>
  sf::st_geometry() |>
  plot(col = "lightblue")

enter image description here

Now, let's filter out the provinces:

provinces <- boundaries$osm_multipolygons |>
  subset(admin_level == 4)

and restrict only to those, which are within Sierra Leone

provinces <- provinces |>
  subset(apply(sf::st_within(provinces, sl, sparse = FALSE), 1, any)) |>
  subset(select = c(osm_id, name))

provinces |>
  sf::st_geometry() |>
  plot(col = RColorBrewer::brewer.pal(5,"Greens"), add = TRUE)

enter image description here

Hope it helps :).

3
  • Wow, thank you so much for your answer! Only thing is, this overloads my CPU and crashes my R session right at the beginning, when making the boundaries object. Maybe it would help if the data could be subset to Sierra Leone in the beginning?
    – ABW
    Sep 27 at 18:54
  • Try download.geofabrik.de/africa.html, there is a shp.zip. I would expect boundaries are there. Otherwise download pbf file and read the data with osmextract package. Sep 27 at 19:07
  • I meant, the file for Sierra Leone from geofabrik :). In the above example the data are subset to Sierra Leone by bounding box, however the nature of overpass is, it returns a bunch of other boundaries as well (those which intersects with bbox). Sep 27 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.