Polar to cartesian coordinates conversion
polar2Projected.RdComputes projected coordinates (Easting, Northing, Altitude) from polar coordinates (Azimuth, Slope, Distance) and center position (Easting, Northing, Altitude). Magnetic declination and meridian convergence are optional parameters. In case distance is measured to the border of objects (e.g. trees), the diameter can be added to compute the coordinates of object center.
Usage
polar2Projected(
x,
y,
z = 0,
azimuth,
dist,
slope = 0,
declination = 0,
convergence = 0,
diameter = 0
)Arguments
- x
vector. easting coordinates of centers in meter
- y
vector. northing coordinates of centers in meter
- z
vector. altitudes of centers in meters
- azimuth
vector. azimuth values from centers in radian
- dist
vector. distances between centers and objects in meter
- slope
vector. slope values from centers in radian
- declination
vector. magnetic declination values in radian
- convergence
vector. meridian convergence values in radian
- diameter
vector. diameters in meter (e.g. in case a radius should be added to the distance)
Value
A data.frame with easting, northing and altitude coordinates, and horizontal distance from centers to objects centers
See also
plot_tree_inventory for tree inventory display
Examples
# create data.frame of trees with polar coordinates and diameters
trees <- data.frame(
x = rep(c(0, 10), each = 2),
y = rep(c(0, 10), each = 2),
z = rep(c(0, 2), each = 2),
azimuth = rep(c(0, pi / 3)),
dist = rep(c(2, 4)),
slope = rep(c(0, pi / 6)),
diameter.cm = c(15, 20, 25, 30)
)
trees
#> x y z azimuth dist slope diameter.cm
#> 1 0 0 0 0.000000 2 0.0000000 15
#> 2 0 0 0 1.047198 4 0.5235988 20
#> 3 10 10 2 0.000000 2 0.0000000 25
#> 4 10 10 2 1.047198 4 0.5235988 30
# compute projected coordinates
polar2Projected(trees$x, trees$y, trees$z, trees$azimuth, trees$dist,
trees$slope,
declination = 0.03, convergence = 0.02, trees$diameter.cm / 100
)
#> x y z d
#> 1 0.1037068 2.072407 0 2.075000
#> 2 3.1718105 1.625558 2 3.564102
#> 3 10.1062057 12.122344 2 2.125000
#> 4 13.2163071 11.648362 4 3.614102