1) If you have an ArcInfo (Advanced) license, you could try Near (Analysis), Point to polygon
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00080000001q000000
Determines the distance from each feature in the input features to the nearest feature in the near features, within the search radius.
Optionally, NEAR_X, NEAR_Y, NEAR_ANGLE, and NEAR_FC fields can also be added to the attribute table of input features as explained in the near features and optional parameters entries.
Set the location parameter to LOCATION to get it to display NEAR_X and NEAR_Y in the output table.
2) Use Calculate Geometry to get the start_x and start_y coordinates of your input point features. Then it's a matter of using XY To Line (Data Management) to draw your lines from start_x, start_y to near_x, near_y.
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000tv000000
One approach is to convert the line into points and find the nearest point. Depending on trade-off between accuracy and processing time, you can select the optimal density of points to create.
Here, I create a point every 1m along the line. Use mapview to check.
library(mapview)
points <- st_line_sample(reach, density = 1/1) %>%
st_sf() %>%
st_cast('POINT')
nearest <- points[which.min(st_distance(site, points)),]
mapview(nearest) + site + reach
Unfortunately even when points are created along a line using st_line_sample()
, they do not intersect the line. I am guessing this is due to rounding. You might have to buffer the point slightly to intersect with the reach.
Going back to your original question (splitting the line at the nearest point), you could then recreate the two segments from the sampled points, like so:
points <- st_line_sample(reach, density = 1/1) %>%
st_sf() %>%
st_cast('POINT') %>%
mutate(group = 1)
which.point <- which.min(st_distance(site, points))
nearest <- points[which.point,]
segment1 <- points[1:which.point,] %>%
group_by(group) %>%
summarise(do_union = FALSE) %>%
st_cast("LINESTRING") %>%
ungroup
segment2 <- points[which.point:nrow(points),] %>%
group_by(group) %>%
summarise(do_union = FALSE) %>%
st_cast("LINESTRING") %>%
ungroup
mapview(segment1, color = 'red') + segment2 + nearest + site
Finally calculate length using st_length:
segment1 %<>% mutate(Length = st_length(.))
Best Answer
Thanks, but not Near_DIST is 0. Search Radius (optional) is must be different "0".
For exp 1 m (in 1 m diameter cicle along nearest-closest points