Antarctica map
On Fri, Oct 31, 2014 at 9:08 PM, Monika Wagner <mw.moni.wagner at gmail.com> wrote:
Hi, I've a problem mapping the antarctica with data from http://www.gadm.org/download. I used this code:
Hello, basically there are dummy points to extend the "longlat" view
of the world to the pole. Obviously these dummy vertices aren't needed
in Orthographic projection, since the polygon surrounds the pole
(rather than trying to traverse a line around a point smeared
impossibly in the plane) but without a reverse pathway to remove them
we have to mess around a bit to hide the tear. You can also turn off
the border colouring and the "tear" becomes invisible (well it does in
base plot, I don't know how to get ggplot2 to do that).
library(raster)
an <- getData("GADM", country = "ATA", level = 0)
## quick check for most southerly lats
lats <- coordinates(as(as(an, "SpatialLines"), "SpatialPoints"))[,2]
## note that lat has been interpolated from the pole to around -86.4
## find the latitude to trim to
nthlat <- 71
latlimit <- min(lats[lats > sort(lats)[nthlat]] )
plot(head(sort(lats), 100))
abline(h = latlimit)
## build a raster to shortcut SpatialPolygons creation
r <- raster(extent(-180, 180, latlimit, 90))
cr <- as(extent(r), "SpatialPolygons")
proj4string(cr) <- CRS(proj4string(an))
library(rgeos)
an0 <- gIntersection(an, cr, byid = TRUE)
## I don't get what happens with geom_path when
## nthlat = 71 (?) but consider using these sources instead:
## https://gis.ccamlr.org/home
## http://www.quantarctica.org/
## or https://data.aad.gov.au/ (offline right this minute)
## set nthlat to 70 for use with geom_path
## another reprojection pathway to prove the point
library(rgdal)
an2 <- spTransform(an0, CRS("+proj=ortho +lat_0=-90 +ellps=WGS84
+datum=WGS84 +no_defs +towgs84=0,0,0"))
plot(an2)
The layer wrld_simpl is a bit tidyier with only the dummy points at
the extremes, these data have been "densified" to insert these
redundant vertices so it looks ok in many (not all) other projections.
There's very good discussions about the ultimate source of the problem here:
http://bost.ocks.org/mike/example/
http://vimeo.com/106198518
BTW, I'm happy to help with any Southern Ocean mapping issues, I've
learnt a whole lot of tricks in recent months.
Cheers, Mike.
library(ggplot2)
load("ATA_adm0.RData")
an<-gadm
antmap<-ggplot()+
geom_path(data=an,aes(x=long,y=lat,group=group))+
scale_y_continuous(limits=c(-90,-50)) +
scale_x_continuous(limits=c(-175,186))
antmap + coord_map("ortho", orientation=c(-90, 0, 0))
Apparently, there is data missing, thus the plot shows some kind of dud
coordinate at the center. Can I somehow delete it and connect the
"beginning" and "end" of the coast line?
Thanks!
Monika
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Michael Sumner Software and Database Engineer Australian Antarctic Division Hobart, Australia e-mail: mdsumner at gmail.com