-1

I manage to create a map and even include a north arrow, but can't get the map.scale to work and getting this kind of error:

Error in map.scale(x = -83, y = 12, ratio = FALSE, relwidth = 0.2, cex = 0.6) : unused arguments (ratio = FALSE, relwidth = 0.2, cex = 0.6)

Here is the code:

    library(maps)
    library(mapdata)  
    library(ggmap)
    library(mapproj)
    library(maptools)  #for shapefiles
    library(scales)  #for transparency
    library(GISTools)
    range <- readShapePoly("isthmanianpacificmoistforestecoregion") #layer      of data for species range
    map("worldHires", c('Cost', 'pan', 'Nic', 'Colombia'),    xlim=c(-89,-75),ylim=c(5,13), col="lightgray", fill=TRUE) #plot the region I want
    map.scale(-81,8,relwidth = 0.15, metric = TRUE, ratio = TRUE)
    plot(range, add=TRUE, xlim=c(-89,-75),ylim=c(5,13), col=alpha("green", 0.6), border=TRUE)  
    map.scale(x=-80, y=10) #, relwidth=0.3, cex=0.5, ratio=FALSE) 
    north.arrow(xb=-77, yb=12, len=0.2, lab="N", col="black", fill=TRUE) # 
dandan78
  • 13,328
  • 13
  • 64
  • 78
CSM
  • 1

1 Answers1

1

The problem is that map.scale() is a function for both maps and GISTools packages. You are trying to use the function from the maps package. Since you are loading first maps and then GISTools, the map.scale() from maps is being masked (probably R throws a warning when loading the last package).

The solution is to specify the package in the function call:

maps::map.scale(-81,8,relwidth = 0.15, metric = TRUE, ratio = TRUE)

Also why two calls to map.scale? You should probably exclude one of them.

Paulo MiraMor
  • 1,582
  • 12
  • 30