View source: R/coordPrecision.r
coordPrecision | R Documentation |
This function calculates the imprecision of geographic coordinates due to rounded coordinate values. See Details for an explanation of how this is calculated.
coordPrecision(x, dms = FALSE, epsilon = 2, distFunct = NULL, ...)
x |
Matrix, data frame, SpatialPoints, or SpatialPointsDataFrame object. If this is a matrix or data frame, the first two columns must represent longitude and latitude (in that order). If |
dms |
Logical, if |
epsilon |
Zero or positive integer, number of digits to which to round seconds value if |
distFunct |
Either a function or |
... |
Arguments to pass to |
For coordinates originally reported in decimal notation, coordinate imprecision is half the distance between the two opposing corners on a bounding box whose size is based on the number of significant digits in the coordinates. This box is defined by 1) finding the maximum number of significant digits after the decimal in the longitude/latitude pair; 2) adding/subtracting 5 to the decimal place that falls just after this; and 3) calculating the distance between these points then dividing by 2. For example, if longitude is 82.37 and latitude 45.8 then the number of significant digits after the decimal place is 2 and 1, respectively so 2 is used on the assumption that latitude is measured to the nearest 100th degree. The precision is then the distance between the point pairs (82.365, 45.795) and (82.375, 45.805). For coordinates originally reported in degree-minus-second (DMS) format, the bounding box is defined by adding/subtracting 0.5 units (degrees, minutes, or seconds, depending on the smallest non-zero unit reported) from the coordinate. For example, if longitude is 90deg 00min 00sec and latitude is 37deg 37min 37sec, then the bounding box will be defined by adding/subtracting 0.5 arcsec to the coordinate.
Numeric values (by default in units of meters).
# coarse-precision cases long <- c(45, 1, 45.1, 5.1) lat <- c(45, 1, 45.1, 5.10) ll <- cbind(long, lat) precision_m <- coordPrecision(ll) cbind(ll, precision_m) # fine-precision cases long <- rep(45, 8) lat <- c(45, 45.1, 45.11, 45.111, 45.1111, 45.11111, 45.111111, 45.1111111) ll <- cbind(long, lat) precision_m <- coordPrecision(ll) cbind(ll, precision_m) # precision varies with latitude long <- rep(45, 181) lat <- seq(-90, 90) ll <- cbind(long, lat) precision_m <- coordPrecision(ll) cbind(ll, precision_m) plot(lat, precision_m / 1000, xlab='Latitude', ylab='Precision (km)') # dateline/polar cases long <- c(0, 180, 45, 45) lat <- c(45, 45, 90, -90) ll <- cbind(long, lat) precision_m <- coordPrecision(ll) cbind(ll, precision_m) # original coordinates in degrees-minutes-seconds format longDD <- c(90, 90, 90, 90, 90, 90) longMM <- c(0, 0, 0, 11, 11, 0) longSS <- c(0, 0, 0, 0, 52, 52) latDD <- c(38, 38, 38, 38, 38, 38) latMM <- c(0, 37, 37, 37, 37, 0) latSS <- c(0, 0, 38, 38, 38, 0) longHemis <- rep('W', 6) latHemis <- rep('N', 6) longDec <- dmsToDecimal(longDD, longMM, longSS, longHemis) latDec <- dmsToDecimal(latDD, latMM, latSS, latHemis) decimal <- cbind(longDec, latDec) coordPrecision(decimal) coordPrecision(decimal, dms=TRUE) ## Not run: # known error when longitude is negative and latitude is -90 long <- -45 lat <- -90 ll <- cbind(long, lat) coordPrecision(ll) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.