[R] intersecting polygons and conversion from decimal degree to km
White.Denis@epamail.epa.gov
White.Denis at epamail.epa.gov
Fri May 24 21:56:43 CEST 2002
> 1. How can I compute the intersecting area between 2 polygons ?
The general case (with interior exclusions and/or concave borders) is a
little work. I don't know whether there are any solutions in R, but
many GIS have this feature.
> 2. I have polygons with coordinates in decimal degrees (i.e. 13
> deg 30 min = 13.5 decimal degrees). I want to compute their area
> and get the results in square meters or square kiometers. Can
> anyone give me a conversion coefficient or a pointer where I can
> find this information (sorry for this off topic question) ?
Here is a very simple map projection that you could use. It ignores the
slightly non-spherical shape of the earth, and is neither equal-area nor
conformal. After converting your geographic coordinates to kilometers
with this function, you can use function "areapl" in package "splancs"
to calculate the area.
marinus <- function (lat, lon) {
# Arguments are vectors of latitude and longitude,
# that is, geographic coordinates in decimal degrees.
# Projection center defined as midpoint in lat-lon space.
# Returns a two column matrix with column names "x" and "y",
# in units of kilometers. This is the equidistant cylindric
# map projection, here named after Marinus of Tyre
# (see JP Snyder. USGS Prof Paper 1395, p 90).
R <- 6371
rlat <- range (lat, na.rm=TRUE)
rlon <- range (lon, na.rm=TRUE)
midlat <- diff (rlat) / 2 + rlat[1]
midlon <- diff (rlon) / 2 + rlon[1]
x <- R * (lon-midlon)*pi/180 * cos (midlat*pi/180)
y <- R * (lat-midlat)*pi/180
xy <- cbind (x=x, y=y)
xy
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list