Re: [R-sig-Geo] Problems with mapmisc::insetMap()

2016-02-26 Thread Patrick Brown
Hi.

1- `insetMap` returns a matrix of x and y coordinates, you needn't
plot all of them.

```
 nica <- getData("GADM", country="NIC", level=0)
 nicabg <- openmap(nica, path="landscape")
 map.new(nicabg,1,mar=c(2, 2, 2, 0) + 0.1)
 plot(nicabg,axes=TRUE)
 plot(nica,add=TRUE)
 loc <- insetMap(nica,pos=c(-89.9,8.5), width=0.3, col=NA, lty=0,pch=".")
 points(loc[1,1], loc[1,2], pch=3)
```

2- `dev.size()` gives you the size of the plotting window.  the best
way to control the plot size is to save it to a file.

```
png("myfile.png", height=400, width=300)
plot(nicabg)
dev.off()
```

p

On Fri, Feb 26, 2016 at 5:02 AM, Agustin Lobo  wrote:
> Much better now!
>
> nica <- getData("GADM", country="NIC", level=0)
> nicabg <- openmap(nica, path="landscape")
> map.new(nicabg,1,mar=c(2, 2, 2, 0) + 0.1)
> plot(nicabg,axes=TRUE)
> plot(nica,add=TRUE)
> loc <- insetMap(nica,pos=c(-89.9,8.5), width=0.3, col=NA, lty=0,pch=".")
> points(loc)
>
> Just 2 questions:
> 1. In the example you provide, the resulting mark is too thick. I've
> made a thinner version with pch=".", but
> it would nice having the option of just drawing the central point and
> not the window.
> 2. Is there a way to calculate the size of the plotting window so that
> there is no wasted white space
> between the map and the axes? I can do this by hand, but then cannot
> read the size.
>
> Thanks
>
> On Thu, Feb 25, 2016 at 6:46 PM, Patrick Brown
>  wrote:
>> Hello all, my first post here!
>>
>>
>> mapmisc (1.4.8 from r-forge) now allows
>>
>>
>> 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)
>> loc = insetMap(nica,pos=c(-85,12), width=0.3, col=NA, lty=0)
>> points(loc)
>>
>> p
>>
>> ___
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Problems with mapmisc::insetMap()

2016-02-26 Thread Agustin Lobo
Much better now!

nica <- getData("GADM", country="NIC", level=0)
nicabg <- openmap(nica, path="landscape")
map.new(nicabg,1,mar=c(2, 2, 2, 0) + 0.1)
plot(nicabg,axes=TRUE)
plot(nica,add=TRUE)
loc <- insetMap(nica,pos=c(-89.9,8.5), width=0.3, col=NA, lty=0,pch=".")
points(loc)

Just 2 questions:
1. In the example you provide, the resulting mark is too thick. I've
made a thinner version with pch=".", but
it would nice having the option of just drawing the central point and
not the window.
2. Is there a way to calculate the size of the plotting window so that
there is no wasted white space
between the map and the axes? I can do this by hand, but then cannot
read the size.

Thanks

On Thu, Feb 25, 2016 at 6:46 PM, Patrick Brown
 wrote:
> Hello all, my first post here!
>
>
> mapmisc (1.4.8 from r-forge) now allows
>
>
> 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)
> loc = insetMap(nica,pos=c(-85,12), width=0.3, col=NA, lty=0)
> points(loc)
>
> p
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Problems with mapmisc::insetMap()

2016-02-25 Thread Patrick Brown
Hello all, my first post here!


mapmisc (1.4.8 from r-forge) now allows


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)
loc = insetMap(nica,pos=c(-85,12), width=0.3, col=NA, lty=0)
points(loc)

p

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Problems with mapmisc::insetMap()

2016-02-25 Thread Agustin Lobo
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  wrote:
> On Thu, Feb 25, 2016 at 4:26 AM, Agustin Lobo  wrote:
>>
>> 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?
>
> 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))
>
>>
>> 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.
>
> The "additional arguments" are for scaleBar, which is also documented
> at ?insetMap.
> Note that there is no ellipsis (...) arg for insetMap.
>
>>
>> Thanks
>>
>> Agus
>>
>> ___
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Problems with mapmisc::insetMap()

2016-02-24 Thread John Baumgartner
On Thu, Feb 25, 2016 at 4:26 AM, Agustin Lobo  wrote:
>
> 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?

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))

>
> 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.

The "additional arguments" are for scaleBar, which is also documented
at ?insetMap.
Note that there is no ellipsis (...) arg for insetMap.

>
> Thanks
>
> Agus
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] Problems with mapmisc::insetMap()

2016-02-24 Thread 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

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo