<html style="direction: ltr;">
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body style="direction: ltr;"
    bidimailui-detected-decoding-type="latin-charset" 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;<br>
     <br>
    <br>
    <div class="moz-cite-prefix">On 22-May-14 11:47 PM, Gerry Creager -
      NOAA Affiliate wrote:<br>
    </div>
    <blockquote
cite="mid:CAFufYD76atwgYKDDhJ7tPiqdutwivAD0kipbJObajSTK8Bsbkw@mail.gmail.com"
      type="cite">
      <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>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>
      </div>
      <br>
      This mail was received via Mail-SeCure System.<br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a>
This mail was received via Mail-SeCure System.


</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Moshav Idan
D.N. Arava, 86840
cell: 0523-665918
<a class="moz-txt-link-freetext" href="http://www.surfaces.co.il">http://www.surfaces.co.il</a></pre>
  </body>
</html>