Dear Frede and Ted, What an absolutely crackerjack for somebody who was begging for such a solution. It worked and worked awfully well. I am grateful! Eliza > From: fr...@vestas.com > To: eliza_bo...@hotmail.com; r-help@r-project.org > Date: Mon, 24 Mar 2014 08:09:26 +0100 > Subject: RE: [R] points with-in boundaries of a map > > Hi Eliza > > I think this comes close to what you want (escaping manual work). > > > library("maps") > library("sp") ## has a point.in.polygon function > > ireland <- map("world", "ireland") > map.axes() > > xr <- range(ireland$x, na.rm = TRUE) > yr <- range(ireland$y, na.rm = TRUE) > xseq <- seq(xr[1], xr[2], by = 0.1) > yseq <- seq(yr[1], yr[2], by = 0.1) > xy <- expand.grid(longitude = xseq, latitude = yseq) > > ## grid lines > abline(v = xseq, col = "grey80", lty = 3) > abline(h = yseq, col = "grey80", lty = 3) > > ## grid points > ireland <- map("world", "ireland") > map.axes() > points(xy, pch = ".") > > ## get ireland map as polygon, only for main island > ## map.poly not exported so use maps:::map.poly > ## use exact to leave out Achill Island and only get main island > ie.polygon <- maps:::map.poly("world", "Ireland", exact = TRUE, as.polygon = > TRUE) > ## x[1] and y[1] added to close polygon > index <- point.in.polygon(xy$longitude, xy$latitude, c(ie.polygon$x, > ie.polygon$x[1]), c(ie.polygon$y, ie.polygon$y[1])) > table(index) > > ireland <- map("world", "Ireland", exact = TRUE) # leaving out Achill > points(xy, pch = ".", cex = 1) > map.axes() > ## index: 0: outside, 1: border, 3: inside > points(xy[index > 0,], pch = 1, col = "red", cex = 0.9) > > ## If you need Achill Island as well then do the same for this region also > print(regionNames <- map("world", "ireland", plot = FALSE, namesonly = TRUE)) > > ireland <- map("world", "Ireland:Achill Island", exact = TRUE, xlim = xr, > ylim = yr) > > Yours sincerely / Med venlig hilsen > > > Frede Aakmann Tøgersen > Specialist, M.Sc., Ph.D. > Plant Performance & Modeling > > Technology & Service Solutions > T +45 9730 5135 > M +45 2547 6050 > fr...@vestas.com > http://www.vestas.com > > Company reg. name: Vestas Wind Systems A/S > This e-mail is subject to our e-mail disclaimer statement. > Please refer to www.vestas.com/legal/notice > If you have received this e-mail in error please contact the sender. > > > > -----Original Message----- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > > On Behalf Of eliza botto > > Sent: 23. marts 2014 03:02 > > To: r-help@r-project.org > > Subject: [R] points with-in boundaries of a map > > > > Dear UseRs, > > I have a question regarding reading the coordinates within a country' map. I > > drew map of ireland by using the following commands > > library("maps") > > library("mapproj") > > map("world", "ireland") > > map.axes() > > You can clearly see the axis labelled. What is want to do is to draw lines > > (both > > vertically and horizontally ) at an interval of 0.5. Which means if x-axis > > starts > > from -10 then the first be on -10 and second on -9.5 and so on. Similar has > > to > > be the case with y-axis. > > Afterwards I only want to read the coordinates of the point falling with in > > the > > boundary of ireland. I spent quite sometime while going through the > > previous posts but couldnt find the answer. > > Thankyou very much in advance, > > Elisa > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@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. [[alternative HTML version deleted]]
______________________________________________ R-help@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.