Skip to content
Prev 5032 / 29559 Next

How to move an island?!

Hi Peter,

In addition to the other people who replied (you can do stuff in 
multiple ways in R :)):

Make two seperate spatial objects, one with the island and one with the 
rest and plot them seperately:

island = dmk[dmk[[3]]=="Bornholm"]
rest = dmk[dmk[[3]]!="Bornholm"]

plot_island = spplot(island, colorkey = FALSE) # get rid of the colorkey
plot_rest = spplot(rest)

print(plot_rest, more = TRUE)
print(plot_island, position = c(c(0.1,0.65,0.30,0.9)))

The position argument specifies the area which plot_island is allowed to 
use. The first two numbers are the lower left corner and the two final 
numbers the upper right corner. The coordinates system is as follows, 
the lower left corner of the plot is (0,0), the upper left is (1,1). You 
have to do some trial and error to find the correct numbers for the 
position argument.

You can also use the coordinate system of your plot (e.g. UTM) to 
specify where the plot needs to be:

require(grid)
print(plot_rest, more = TRUE)
trellis.focus()  # This is to focus on your plot, important later on...
# The bbox for your subplot in the coor system of your data
coor_in_your_system = unit(c(a,b,c,d), "native")
# Convert it to the (0,0) to (1,1) system
position_vector = convertX(coor_in_your_system, "npc")
trellis.unfocus()
print(plot_island, position = position_vector)

See ?grid.convert and ?unit for more details. I hope this last section 
is clear, if not, do not hesitate to send an e-mail.

cheers,
Paul
Peter Jepsen wrote: