An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110922/5708637a/attachment.pl>
Distance from coast
5 messages · Sandeep Patil, Michael Sumner, Kemp, Michael +2 more
Here's a really simple example using the default low res longlat
coastline in the maps package. It should work for any coastal dataset
that can extract the raw coordinates from, though there's no attempts
at efficiency. spDistsN1 is really fast and works well for this
though, be careful to use longlat argument correctly.
library(sp)
library(maps)
## single point for a simple test
pts <- matrix(c(-88, 36), ncol = 2)
## simple map data
mp <- map("usa", plot = FALSE)
## convert coords to matrix and dump NA
xy.coast <- cbind(mp$x, mp$y)[!is.na(mp$x), ]
## container for all the nearest points matching the input
closest.points <- matrix(0, ncol = 2, nrow = nrow(pts))
for (i in 1:nrow(pts)) {
closest.points[i, 1:2] <- xy.coast[which.min(spDistsN1(xy.coast,
pts, longlat = TRUE)), ]
}
map(mp)
points(pts)
points(closest.points)
Cheers, Mike.
On Fri, Sep 23, 2011 at 1:11 PM, Sandeep Patil
<sandeep.coepcivil at gmail.com> wrote:
Hello does anyone know of any R -script or function which will give the value of nearest distance from coast of a point in USA. I have a number of latitude and longitude values spread evenly across USA and i want to find the nearest distance from coast for each of these points. If not a function can anyone suggest me a strong library for geographical data manipulation. Thanks a lot Sandeep ? ? ? ?[[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 Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsumner at gmail.com
Hello Sandeep, Tom Hengl has some world maps on his spatial-analyst website, one of which is a 'distance-to-the-coast' map. He also has some example script for how to handle these maps. See... http://spatial-analyst.net/wiki/index.php?title=Global_datasets Regards, Michael -----Original Message----- From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Sandeep Patil Sent: Friday, September 23, 2011 5:11 AM To: r-sig-geo at r-project.org Subject: [R-sig-Geo] Distance from coast Hello does anyone know of any R -script or function which will give the value of nearest distance from coast of a point in USA. I have a number of latitude and longitude values spread evenly across USA and i want to find the nearest distance from coast for each of these points. If not a function can anyone suggest me a strong library for geographical data manipulation. Thanks a lot Sandeep _______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Sandeep, You probably want to use: http://commons.wikimedia.org/wiki/File:Dist2con.png *I had some problems automatic the processing with R+SAGA (will try to update the maps/scripts soon), but this is probably what you are looking for. The geotifs are at: http://spatial-analyst.net/worldmaps/ *we are in process of migrating to www.worldgrids.org which will include both data and the geo-services. cheers, T. Hengl http://www.wewur.wur.nl/popups/vcard.aspx?id=HENGL001
Hello Sandeep, Tom Hengl has some world maps on his spatial-analyst website, one of which is a 'distance-to-the-coast' map. He also has some example script for how to handle these maps. See... http://spatial-analyst.net/wiki/index.php?title=Global_datasets Regards, Michael -----Original Message----- From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Sandeep Patil Sent: Friday, September 23, 2011 5:11 AM To: r-sig-geo at r-project.org Subject: [R-sig-Geo] Distance from coast Hello does anyone know of any R -script or function which will give the value of nearest distance from coast of a point in USA. I have a number of latitude and longitude values spread evenly across USA and i want to find the nearest distance from coast for each of these points. If not a function can anyone suggest me a strong library for geographical data manipulation. Thanks a lot Sandeep [[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 _______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110923/a40ade2f/attachment.pl>