0

I have been wrestling with an error (that I am clearly making) in trying to add an arrow on the bottom right of an otherwise functional sp plot. I am using sp.layout and a SpatialPolygonsDataFrame.

The dimensions are: xmin, 29.122917, xmax, 29.20292, ymin, -3.445416, ymax, -3.33875 The

Here is my code:

north <- list("SpatialPolygonsRescale", layout.north.arrow(), 
              offset = c(29.15, -3.44), scale = 500)

spplot(population_raster100mshp, 
       scales=list(draw = TRUE), 
       lwd=0, par.settings = list(axis.line = list(col = "transparent")), cex.main=0.8,
       sp.layout = list(north))

This produces the plot and axes, but no arrow. I have tried moving around the offset, but it does not appear at all.

What am I missing?

2
  • Hard to help without knowing what population_raster100mshp is. Your line that starts "The dimension is" seems cut off. What does summary of that object tell us?
    – Spacedman
    Nov 25, 2023 at 14:31
  • Thanks as always @Spacedman. It is a SpatialPolygonsDataFrame, specifically: > Object of class SpatialPolygonsDataFrame Coordinates: min max x 29.122083 29.20542 y -3.447083 -3.33875 Is projected: FALSE proj4string : [+proj=longlat +datum=WGS84 +no_defs]
    – rratnaya
    Nov 27, 2023 at 20:32

1 Answer 1

1

Your scale of 500 is way too big for your lat-long degree data.

Simplifying a bit, and with a population_raster100mshp which is two points at your bounding box limits with a Z value for colouring:

north = list("SpatialPolygonsRescale", layout.north.arrow(), 
              offset = c(29.15, -3.44), scale =.010)
spplot(population_raster100mshp,"Z",sp.layout=list(north))

enter image description here

1
  • The scale was the issue. Thank you for your insights!
    – rratnaya
    Nov 28, 2023 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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