[R-sig-Geo] Plotting continuous data (gridded) clipped to shape boundary
Shawn P. Serbin
serbin at wisc.edu
Wed Feb 27 16:57:25 CET 2008
All,
I was hoping there was someone (or several folks) who could assist me. I
have spent some time lately trying to figure out a way to plot gridded
data in Latitude and Longitude values with a map overlay and ultimately
the gridded data would be clipped to the boundary of the map, i.e. a
Wisconsin state boundary shapefile (either custom or from the maps
package). The idea is to create code that can inject netCDF output and
quickly create maps that can be used in presentations/publications.
I have cleared the first hurdle (well not really a hurdle) and have a
pretty clean way of importing the netCDF files into R arrays, vectors,
data.frames (I guess these would be considered Spatial.data.frames)
which I can then manipulate.
The problem lies with the actual mapping. Now I can easily map the data
in the Lattice package(s) and display a very nice, custom legend bar
with contour overlays. However, when I try to use “image” in the
spatstat package either 1) I can only view the data on a standard grid
(i.e. 0 to 1 in the x and y) or 2) I get an error message letting me
know that “expecting increasing x and y” or 3) “x does not increase
consistently”
Again, I have tried many mapping and spatial packages but have yet to
find one that can handle the lat and long as well as clipping to a
boundary. Now I have seen an example on the web where using image you
can create a binary mask (i.e. meuse) but have yet to see how I can get
this to work with a vector shapefile. If I could get this to work with
plotting lat and long in image I think I would be good to go.
Alternatively, if there is a package that can handle what I am looking
to do then that would be great as well. It seems however that I am
having difficulty getting the data in the correct format and / or using
the correct plotting.
What I would like to do is something similar to the “volcano” demo where
I plot the gridded data (in native 8km grid cell resolution) then
overlay contours of my chosen spacing and the clip the data to
Wisconsin, with Lat and Long x and y and a legend bar.
Thanks in advance to any and all who are better at this than me!
Shawn
More information about the R-sig-Geo
mailing list