[R] filled maps
Roger Bivand
Roger.Bivand at nhh.no
Tue Feb 3 11:34:06 CET 2004
On Tue, 3 Feb 2004, Janus Larsen wrote:
> Hi R-Help,
>
> I would like to make filled contour maps of ocean data overlaid by
> costlines from the map package.
> I can draw the filled contours and the coastlines om the same plot, but
> the filled contour also covers part of the land. To get rid of that I
> tried to draw a filled coastline map on top of the filled contour, but
> the filled map only draws the closed contours - so most of the land is
> missing.
> Example:
> map("worldHires",xlim=c(0,15),ylim=c(50,60)) #Draw relevant region
> (North Sea and Denmark waters)
> map("worldHires",xlim=c(0,15),ylim=c(50,60),fill=TRUE) # This only draws
> Denmark and Holland (Sweden, uk, Germany etc. disappears because they
> are not closed polygons).
Looks as though you can use the regions= argument:
> res <- map("worldHires",xlim=c(0,15),ylim=c(50,60), plot=FALSE,
+ namesonly=TRUE)
> res
[1] "Denmark" "USSR"
[3] "Netherlands" "Netherlands:IJsselmeer"
[5] "France" "Czechoslovakia"
[7] "Poland" "Germany"
[9] "Luxembourg" "Belgium"
[11] "Norway" "Sweden"
[13] "Germany:Usedom" "Netherlands:South"
[15] "Germany:Langeoog" "Denmark:Mors"
[17] "Denmark:Mon" "Lake Fjerritslev"
[19] "UK:Great Britain" "Denmark:Samso"
[21] "Netherlands:Ameland" "Netherlands:Terschelling"
[23] "Denmark:Als" "Denmark:Sjaelland"
[25] "Denmark:Fyn" "Netherlands:Schiermonnikoog"
[27] "Denmark:Laeso" "Sweden:Orust"
[29] "Germany:Borkum" "Denmark:Lolland"
[31] "Netherlands:Texel" "Netherlands:Flevoland"
[33] "Norway:Sunnhordland" "UK:Isle of Sheppey"
[35] "Denmark:Langeland" "Denmark:Bornholm"
[37] "Germany:Fehmarn" "Germany:Rugen"
[39] "Germany:Norderney" "Norway:Karmoy"
> map("worldHires",xlim=c(0,15),ylim=c(50,60))
> map("worldHires",regions=res, fill=TRUE, add=TRUE)
fixes it for me. Curiously, the longitudes add 2.5 degrees on each side.
Roger
PS. For film viewers who enjoyed "Good bye, Lenin!", we still provide
region="USSR" above!
>
> Any hint on how to fix this problem or a different approach is most
> welcome.
> Janus
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Roger Bivand
Econonic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway, voice: +47-55959355, fax: +47-55959393; Roger.Bivand at nhh.no
More information about the R-help
mailing list