<div dir="ltr">The inherent problem is that the point will be arbitrarily specified. I need to find the 4 points in the table 'sites' (it has label, geom, and lat, lon columns) closest to an arbitrary point given a lat/lon coordinate pair.<div>
<br></div><div>Or, am I making this harder than I think I am?</div><div><br></div><div>Thanks!</div><div>gerry</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 23, 2014 at 5:49 AM, Micha Silver <span dir="ltr"><<a href="mailto:micha@arava.co.il" target="_blank">micha@arava.co.il</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="direction:ltr" text="#000000" bgcolor="#FFFFFF">
Use ORDER BY and LIMIT 4 to get the nearest 4 points:<br>
Assuming your point table is called poi, and it has a 'geom' column,
and a 'label' column, and "lon' and 'lat' give the coordinates of
the starting location, then<br>
SELECT poi.label, ST_Distance(poi.geom, MakePoint(lon, lat)) AS dist
<br>
FROM poi<br>
ORDER BY dist ASC LIMIT 4;<div><div class="h5"><br>
<br>
<br>
<div>On 22-May-14 11:47 PM, Gerry Creager -
NOAA Affiliate wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">I need to query a rather smallish database and
return 4 points closest to a lat/lon (or lon/lat, if you prefer)
statement. I've been off-line from PostGIS and my skills are
worse than rusty right now...
<div>
<br>
</div>
<div>Thanks</div>
<div>Gerry<br>
-- <br>
<div dir="ltr">Gerry Creager
<div>NSSL/CIMMS</div>
<div><a href="tel:405.325.6371" value="+14053256371" target="_blank">405.325.6371</a></div>
<div>++++++++++++++++++++++</div>
<div>
<div>“Big whorls have little whorls,</div>
<div>That feed on their velocity; </div>
<div>And little whorls have lesser whorls, </div>
<div>And so on to viscosity.” </div>
<div>Lewis Fry Richardson (1881-1953)</div>
</div>
</div>
</div>
</div>
<br></div></div>
This mail was received via Mail-SeCure System.<br>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
postgis-users mailing list
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a>
This mail was received via Mail-SeCure System.
</pre><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<pre cols="72">--
Moshav Idan
D.N. Arava, 86840
cell: 0523-665918
<a href="http://www.surfaces.co.il" target="_blank">http://www.surfaces.co.il</a></pre>
</font></span></div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">
Gerry Creager<div>NSSL/CIMMS</div><div>405.325.6371</div><div>++++++++++++++++++++++</div><div><div>“Big whorls have little whorls,</div><div>That feed on their velocity; </div><div>And little whorls have lesser whorls, </div>
<div>And so on to viscosity.” </div><div>Lewis Fry Richardson (1881-1953)</div></div></div>
</div>