snapPointsToLines

0th

Percentile

Snap a set of points to a set of lines

This function snaps a set of points to a set of lines based on the minimum distance of each point to any of the lines. This function does not work with geographic coordinates.

Keywords
spatial
Usage
snapPointsToLines(points, lines, maxDist=0.1, withAttrs = TRUE, idField=NA)
Arguments
points

An object of the class SpatialPoints or SpatialPointsDataFrame.

lines

An object of the class SpatialLines or SpatialLinesDataFrame.

maxDist

Numeric value for establishing a maximum distance to avoid snapping points that are farther apart; its default value is set from 7 February 2019 to 0.1, but this value may not be appropriate for all settings.

withAttrs

Boolean value for preserving (TRUE) or getting rid (FALSE) of the original point attributes. Default: TRUE. This parameter is optional.

idField

A string specifying the field which contains each line's id. This id will be transferred to the snapped points data set to distinguish the line which each point was snapped to.

Value

SpatialPointsDataFrame object as defined by the R package 'sp'. This object contains the snapped points, therefore all of them lie on the lines.

Aliases
• snapPointsToLines
Examples
# NOT RUN {
# From the sp vignette
l1 = cbind(c(1,2,3),c(3,2,2))
l1a = cbind(l1[,1]+.05,l1[,2]+.05)
l2 = cbind(c(1,2,3),c(1,1.5,1))
Sl1 = Line(l1)
Sl1a = Line(l1a)
Sl2 = Line(l2)
S1 = Lines(list(Sl1, Sl1a), ID="a")
S2 = Lines(list(Sl2), ID="b")
Sl = SpatialLines(list(S1,S2))
df = data.frame(z = c(1,2), row.names=sapply(slot(Sl, "lines"), function(x) slot(x, "ID")))
Sldf = SpatialLinesDataFrame(Sl, data = df)

xc = c(1.2,1.5,2.5)
yc = c(1.5,2.2,1.6)
Spoints = SpatialPoints(cbind(xc, yc))

if (rgeosStatus()) snapPointsToLines(Spoints, Sldf, maxDist=0.4)
# }
Documentation reproduced from package maptools, version 0.9-5, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.
{"ft_lang_label":"__label__en","ft_lang_prob":0.68391067,"math_prob":0.9945872,"size":1771,"snap":"2019-43-2019-47","text_gpt3_token_len":528,"char_repetition_ratio":0.12450481,"word_repetition_ratio":0.05283019,"special_character_ratio":0.2891022,"punctuation_ratio":0.17204301,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96906173,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-17T20:46:50Z\",\"WARC-Record-ID\":\"<urn:uuid:8e9fd6ad-8066-4005-8a36-4e0424d06098>\",\"Content-Length\":\"15689\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f866b83c-85c4-4e9d-8c68-f3f3ff48b3dd>\",\"WARC-Concurrent-To\":\"<urn:uuid:2c6fecc9-f032-42c8-9fe5-5fa8a1ca0096>\",\"WARC-IP-Address\":\"184.73.26.74\",\"WARC-Target-URI\":\"https://www.rdocumentation.org/packages/maptools/versions/0.9-5/topics/snapPointsToLines\",\"WARC-Payload-Digest\":\"sha1:UTUIKQPQT5E6VRCVLJXVCBPZUUX2ZVSS\",\"WARC-Block-Digest\":\"sha1:PEWMSJGNSPRXKNU7R43BVJG3IDJ6XU3B\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986676227.57_warc_CC-MAIN-20191017200101-20191017223601-00404.warc.gz\"}"}