<html style="direction: ltr;">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;" bidimailui-charset-is-forced="true"
bgcolor="#FFFFFF" text="#000000">
I use a few GRASS procedures to snap points to a line (i.e. snap
gauges to a stream network) as follows:<br>
<br>
<tt># Add columns to the stations vector for snapped_x and snapped_y
and get coordinates </tt><tt><br>
</tt><tt>echo -e "\n** Snapping stations to streams **"</tt><tt><br>
</tt><tt>v.db.addcolumn --q map=$POINTS columns="snap_x double,
snap_y double"</tt><tt><br>
</tt><tt># Temporatily change region stations input vector, and get
snap coords</tt><tt><br>
</tt><tt># so that all stations get the correct snap coords - even
those outside current domain </tt><tt><br>
</tt><tt>v.distance --q --o from=stations to=streams
output=connectors upload=to_x,to_y column=snap_x,snap_y</tt><tt><br>
</tt><tt># Create a new stations vector with the snap_x and snap_y
columns </tt><tt><br>
</tt><tt>g.remove -f vect name=frxst_pts</tt><tt><br>
</tt><tt># Use v.out.ascii with -r option to export only drainage
point in current region (domain)</tt><tt><br>
</tt><tt># snap_x and snap_y columns become the X-Y coordinates for
frxst_pts point vector</tt><tt><br>
</tt><tt>v.out.ascii --q -r -c stations
columns="id,station_name,station_num,longitude,latitude,snap_x,snap_y"
separator=comma | v.in.ascii --q --o input=- output=frxst_pts x=8
y=9 cat=3 columns="east double,north double,id
integer,station_name text,station_num integer,longitude
double,latitude double,snap_x double,snap_y double"
separator=comma skip=1</tt><br>
<br>
The crux of the above commands is the "v.distance" line. This
command checks the distance from each point to the line, and uploads
to the line vector the x-y coordinates of intersection. This
distance is the length of the perpendicular from the point to the
line.<br>
Then the last command "v.in.ascii ... | v.out.ascii ..." takes those
point coordinates, and exports to a new point vector.<br>
<br>
The problem with the PostGIS function ST_ClosestPoint is that it
finds the closest vertex that *already exists* on the line feature.
So if one of the points is near to a straight line segment, the
chosen vertex might be actually far from the point.<br>
<br>
HTH,<br>
<br>
<div class="moz-cite-prefix">On 06/30/2016 03:18 PM, Tyler Veinot
wrote:<br>
</div>
<blockquote
cite="mid:CANfsH32sjOPY-pYGuF3LfMnmEJLfPdvru_qnMCdF93FXokEezQ@mail.gmail.com"
type="cite">
<div dir="ltr">Bump!
<div>Nobody? Am I looking at having to use some PostGIS
functions to accomplish this?</div>
<div>Tyler</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Jun 29, 2016 at 8:57 AM, Tyler
Veinot <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:tylerkveinot@gmail.com" target="_blank">tylerkveinot@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi All;
<div>I have a point file and a line file. I want to move
all non-intersecting points to the line position closest
to them. Does QGIS have a tool for that? Is there a
plugin?</div>
<div>Cheers</div>
<span class="HOEnZb"><font color="#888888">
<div>Tyler</div>
</font></span></div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
</blockquote>
<br>
</body>
</html>