<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">The distance should be in the projection units, which for 4326 is decimal degrees, and if you want meters you'll need to convert the results to meters.<div><br></div><div>But first, I suspect your data is not in 4326 then if you get 1179. Make sure you are using the SRID when inserting them</div><div><br></div><div><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">update address set geog=ST_GeographyFromText('POINT('||lon||' '||lat||')',4326) where id=?;</blockquote></div></blockquote></div><div><pre class="programlisting"><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="white-space: normal;">Also see</span></font></pre><pre class="programlisting"><span class="Apple-style-span" style="font-family: Helvetica; white-space: normal; "><a href="http://postgis.refractions.net/docs/ST_Distance.html">http://postgis.refractions.net/docs/ST_Distance.html</a></span></pre></div><div>hth</div><div>charles</div><div><br><div><div><div>On Mar 13, 2012, at 2:58 AM, Stuart Guthrie wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Could it be returning a distance in decimal miles? I'm out by around 1.6 - 1.6km = 1mile?<br><br><div class="gmail_quote">On Tue, Mar 13, 2012 at 5:43 PM, Stuart Guthrie <span dir="ltr"><<a href="mailto:stuartguthrie@gmail.com">stuartguthrie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">OK, I'm a newbie to postgis but an old-timer with open source in general.<br><br>Sorry to bother everyone but this problem is driving me a little nuts.<br>
<br>I've bought the 'postgis in action' book and now I think I still know nothing.<br>
<br>I'm trying to store long lats and do queries on them to establish distance and use that for reporting.<br><br>I'm using this to update the table 'address' <br><br>update address set geog=ST_GeographyFromText('POINT('||lon||' '||lat||')') where id=?;<br>
<br>the address table field 'geog' has this definition:<br><br> geog geography(Point,4326) <br><br>When I compare two addresses that I know are around 1800m apart I get this:<br><br>select a.addressline2, a.suburb, ST_Y(a.geog::geometry), ST_X(a.geog::geometry), b.addressline2,b.suburb,ST_Y(b.geog::geometry), ST_X(b.geog::geometry), ST_distance(a.geog,b.geog ) from address a join address b on <a href="http://b.id/" target="_blank">b.id</a>=41491 where <a href="http://a.id/" target="_blank">a.id</a>=1238 ;<br>
<br>addressline2 | suburb | st_y | st_x | addressline2 | suburb | st_y | st_x | st_distance <br>---------------+--------+-------------+-------------+----------------+-------------+-------------+-------------+------------------<br>
140 Sussex St | Sydney | -33.8692429 | 151.2036312 | 1 Riley Street | Surry Hills | -33.8726426 | 151.2157115 | 1179.61881540556<br><br>Postgis says they are 1179.61m apart.<br clear="all"><br></blockquote></div></blockquote></div><br></div></div></body></html>