Skip to content

Problems with mapmisc::insetMap()

3 messages · John Baumgartner, Agustin Lobo

#
Hi!

When I make an insetMap for an small country, I get a very
uggly "X" marking its position:

require(rgdal)
require(raster)
require(mapmisc)
nica <- getData("GADM", country="NIC", level=0)
nicabg <- openmap(nica, path="landscape")
map.new(nicabg, 0.7,mar=c(2, 2, 2, 0) + 0.1)
plot(nicabg,axes=TRUE)
plot(nica,add=TRUE)
insetMap(nica,"bottomleft", width=0.3)

is there a way to set another symbol or at least making it smaller?

Also, despite the help page says that
"Additional arguments passed to legend" are accepted, I do not find
any to actually work.
For example, cannot set the exact values of x,y for positioning the
inset map. And cannot use locate() to put it wherever I want to.

Thanks

Agus
#
On Thu, Feb 25, 2016 at 4:26 AM, Agustin Lobo <alobolistas at gmail.com> wrote:
Not quite what you asked for, but you could try TeachingDemos::subplots,
which you might find to be a little more flexible.

E.g.

library(TeachingDemos)
library(rgdal)

download.file(file.path('http://www.naturalearthdata.com/http/',
                        'www.naturalearthdata.com/download/110m/physical',
                        'ne_110m_land.zip'), f <- tempfile())
unzip(f, exdir=tempdir())
world <- readOGR(tempdir(), 'ne_110m_land')

plot(nica, col='gray90', border='black', axes=TRUE, xlim=c(-88, -81.5))
subplot({
  plot(world, col=1, xlim=c(-120, 30), ylim=c(-30, 40))
  box()
  points(coordinates(nica), pch=20, cex=2, col='red')
}, 'bottomright', inset=c(0.01, 0.01), size=c(1, 1))
The "additional arguments" are for scaleBar, which is also documented
at ?insetMap.
Note that there is no ellipsis (...) arg for insetMap.
#
Thanks,

Do you know why your solution does not work on a raster layer?
i.e.

require(rgdal)
require(raster)
require(mapmisc)
require(TeachingDemos)

nicabg2 <- openmap(nica,path="cartodb")
plot(nicabg2)
subplot({
    plot(world, col=1, xlim=c(-120, 30), ylim=c(-30, 40))
    box()
    points(coordinates(nica), pch=20, cex=2, col='red')
}, 'bottomright', inset=c(0.01, 0.01), size=c(1, 1))

Agus
On Thu, Feb 25, 2016 at 12:36 AM, John Baumgartner <johnbaums at gmail.com> wrote: