Skip to content
Prev 24366 / 29559 Next

Mask a map using statistical significance

Thanks Barry and Arnaud (off-list) for the valuable hints.
I ended up managing to use rasterVis' levelplot to produce the map I was looking for.
The key step was to convert the raster I wanted to use as a mask to SpatialPoints, and then pass it as an additional layer to levelplot.
The final map, produced using my actual data, can be visualized here:?https://dl.dropboxusercontent.com/u/27700634/rainfall_trend.png.?Stippling indicates regions exceeding the 95% statistical significance.
?
| ? |
| ? |  | ? | ? | ? | ? | ? |
|  |
|  |
| View on dl.dropboxuserconten... | Preview by Yahoo |
|  |
| ? |


Greetings,
?-- Thiago V. dos Santos

PhD student
Land and Atmospheric Science
University of Minnesota
On Wednesday, May 4, 2016 11:02 AM, Barry Rowlingson <b.rowlingson at lancaster.ac.uk> wrote:
Your example looks a bit rubbish because you have mostly isolated
pixels. Let's make an example with an area so we can see the shading.
[1] 0.00000000 0.01041667

now convert your raster to polygons at the threshold you are
interested in. Let's imagine the area less than 0.001 (the central
circle here):

p_poly = rasterToPolygons(r.pvalue<0.001, dissolve=TRUE)

and overlay hatched polygons:

plot(r.pvalue) # or whatever your underlying data is
plot(p_poly[p_poly$layer==1,],density=5,add=TRUE, border=NA)

see help(polygon) for parameters to control the shading angle and
density. The "border=NA" above hides the outline which looks like
those maps you linked to.

Barry




On Wed, May 4, 2016 at 12:11 AM, Thiago V. dos Santos via R-sig-Geo
<r-sig-geo at r-project.org> wrote: