Linear referencing
Usage
s2_project(x, y, radius = s2_earth_radius_meters())
s2_project_normalized(x, y)
s2_interpolate(x, distance, radius = s2_earth_radius_meters())
s2_interpolate_normalized(x, distance_normalized)
Arguments
- x
A simple polyline geography vector
- y
A simple point geography vector. The point will be snapped to the nearest point on
x
for the purposes of interpolation.- radius
Radius of the earth. Defaults to the average radius of the earth in meters as defined by
s2_earth_radius_meters()
.- distance
A distance along
x
inradius
units.- distance_normalized
A
distance
normalized tos2_length()
ofx
.
Value
s2_interpolate()
returns the point onx
,distance
meters along the line.s2_interpolate_normalized()
returns the point onx
interpolated to a fraction along the line.s2_project()
returns thedistance
thatpoint
occurs alongx
.s2_project_normalized()
returns thedistance_normalized
alongx
wherepoint
occurs.
Examples
s2_project_normalized("LINESTRING (0 0, 0 90)", "POINT (0 22.5)")
#> [1] 0.25
s2_project("LINESTRING (0 0, 0 90)", "POINT (0 22.5)")
#> [1] 2501890
s2_interpolate_normalized("LINESTRING (0 0, 0 90)", 0.25)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (0 22.5)
s2_interpolate("LINESTRING (0 0, 0 90)", 2501890)
#> <geodesic s2_geography[1] with CRS=OGC:CRS84>
#> [1] POINT (0 22.500002)