[R] Blank certain areas of a contour plot

Duncan Murdoch murdoch at stats.uwo.ca
Wed Sep 17 21:40:48 CEST 2008


On 9/17/2008 2:29 PM, Victor Homar wrote:
>    Thanks a lot for your suggestion but...
>    Can  I  do that using the/a land-sea information from the 'worldHires'
>    database (from mapdata)?

Yes, you use the map.where function to identify the location of the 
points.  If NA, it's out in the ocean somewhere.  Some lakes and 
interior seas will probably be identified by name.  For example, here's 
what I get when clicking on some regions in the world map:

 > map("world")
 > loc <- locator()
 > loc
$x
[1]  -47.35604 -150.58010 -114.14808  -86.82406

$y
[1] 33.67133 42.77815 62.20602 44.59951

 > map.where(x=loc$x, y=loc$y)
[1] NA
[2] NA
[3] "Canada"
[4] "Great Lakes:Superior, Huron, Michigan"

I believe all of those locations were in the oceans (1 and 2) or lakes 
(3 and 4).

Duncan Murdoch

>    Best,
>    Víctor.
>    Greg Snow wrote:
> 
> After you have interpolated your data, replace the values in the areas of the o
> cean with NA, then filled.contour will not plot in those areas.
> 
> Hope this helps,
> 
>   
> 
> -----Original Message-----
> From: [1]r-help-bounces at r-project.org [[2]mailto:r-help-bounces at r-
> project.org] On Behalf Of Victor Homar
> Sent: Tuesday, September 16, 2008 9:54 AM
> To: [3]r-help at r-project.org
> Subject: [R] Blank certain areas of a contour plot
> 
> Hi,
> 
> I'm interpolating a list of syncronous accumulated precipitation
> observations collected over a number of raingauge stations sited over
> land, over a regular lat/lon grid using akima's interp().
> 
> Then, I plot and locate geographycally the resulting field with a
> filled.contour() and a call to map(). Everything is fine but I need to
> "blank" (in Golden Surfer nomenclature) the areas of my domain that lay
> over the sea, as I do not have observations there and structures are
> completely artificial.
> 
> Is there any function out there that can use the mapsdata database to
> "blank" the sea areas of my plot?
> Otherwise, can anybody think of a shortcut to get a similar effect on
> the final map (not showing the interpolated precipitation areas over
> the
> sea?
> 
> Thanks a lot in advance,
> 
> Víctor.
> 
> --
> -----------------------------------------------------------------------
> Víctor Homar Santaner
> Grup de Meteorologia
> 
> Edif. Mateu Orfila                      Tel: +34 971 17 1376
> Universitat de les Illes Balears        Fax: +34 971 17 3426
> 07122 Palma de Mallorca (SPAIN)         Email: [4]Victor.Homar at uib.es
> 
>               Knowledge is contagious. Infect truth.
> 
> ______________________________________________
> [5]R-help at r-project.org mailing list
> [6]https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide [7]http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 
> 
> 
> --
> -----------------------------------------------------------------------
> Víctor Homar Santaner
> Grup de Meteorologia
> 
> Edif. Mateu Orfila                      Tel: +34 971 17 1376
> Universitat de les Illes Balears        Fax: +34 971 17 3426
> 07122 Palma de Mallorca (SPAIN)         Email: [8]Victor.Homar at uib.es
> 
>               Knowledge is contagious. Infect truth.
> -----------------------------------------------------------------------
> 
> References
> 
>    1. mailto:r-help-bounces at r-project.org
>    2. mailto:r-help-bounces at r
>    3. mailto:r-help at r-project.org
>    4. mailto:Victor.Homar at uib.es
>    5. mailto:R-help at r-project.org
>    6. https://stat.ethz.ch/mailman/listinfo/r-help
>    7. http://www.R-project.org/posting
>    8. mailto:Victor.Homar at uib.es
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list