Skip to content
Prev 17504 / 29559 Next

how to display a projected map on an rasterVis::layerplot?

summary: How to convert from a simple (x,y) matrix (as produced by
M3::get.map.lines.M3.proj) to a SpatialLines, or to coordinates
consumable by latticeExtra::layer?

details:

Perhaps I should have asked the question above first, instead of
putting it at the end of

http://stackoverflow.com/questions/14865507/how-to-display-a-projected-map-on-an-rlatticelayerplot

where it is obviously overlooked :-( The problem is also explained
there:

http://stackoverflow.com/questions/14865507/how-to-display-a-projected-map-on-an-rlatticelayerplot (formatted for mail)
However I can
Note how these grid coordinates derive linearly from the IOAPI
metadata above, and to the raster bounds (farther above): e.g.,

map.lines.XY.min.raw <-
  c(-2272238,-1567156) # from summary(map.lines$coords)
x.orig       <- -2736000
x.cell.width <- 36000
y.orig       <- -2088000
y.cell.width <- 36000

map.lines.XY.min.IOAPI <- c(
  (map.lines.XY.min.raw[1] - x.orig)/x.cell.width,
  (map.lines.XY.min.raw[2] - y.orig)/y.cell.width
)
map.lines.XY.min.IOAPI
# [1] 12.88228 14.46789

Looking @ 

http://i.stack.imgur.com/eijZI.png (example 2)

eyeball the intersection of the latitude of south tip of Texas with
the westernmost longitude of California. Then look at the
corresponding location in

http://i.stack.imgur.com/z7OA0.png (example 1)

you will see that corresponding example1 coordinates are approximately
(12.88228,14.46789) as computed above. Hardly a proof :-) but the this
certainly shows that the transform from `map.lines`-coordinates to
IOAPI-coordinates is straightforward. So what I need to know, in order
to feed output from M3::get.map.lines.M3.proj(...) to
latticeExtra::layer(...), is how to set the coordinates of a
SpatialLines as produced by, e.g.,
or
or otherwise how to set the (x,y) coordinates being read by
latticeExtra::layer(...)

TIA, Tom Roche <Tom_Roche at pobox.com>