How is your query calculating the distance between a point and a line? Are you not just calculating the length of the line?<br><br><div class="gmail_quote">2009/7/10 Pavel Iacovlev <span dir="ltr"><<a href="mailto:iacovlev.pavel@gmail.com">iacovlev.pavel@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Works on lines for me:<br>
<br>
QUERY:<br>
select ST_length_spheroid(st_transform(the_geom, 4326),<br>
'SPHEROID["GRS_1980",6378137,298.257222101]') as ellps_distance,<br>
st_distance(the_geom) as normal_distance from fondcart_layers.roads<br>
limit 1<br>
<br>
RESULT:<br>
ellps_distance: 9214.65310341668<br>
normal_distance: 9214.10811677981<br>
<div><div></div><div class="h5"><br>
2009/7/10 Peter Kukuča <<a href="mailto:pjr.kukuca@gmail.com">pjr.kukuca@gmail.com</a>>:<br>
> ST_Length_spheroid is perfectly great, but it does not take a line as an<br>
> input :-(<br>
><br>
> 2009/7/10 Pavel Iacovlev <<a href="mailto:iacovlev.pavel@gmail.com">iacovlev.pavel@gmail.com</a>><br>
>><br>
>> And for geometry length use ST_length_spheroid(geometry,spheroid)<br>
>><br>
>> On Fri, Jul 10, 2009 at 11:48 AM, Pavel<br>
>> Iacovlev<<a href="mailto:iacovlev.pavel@gmail.com">iacovlev.pavel@gmail.com</a>> wrote:<br>
>> > you can take the middle of the line, st_line_interpolate_point(the_geom,<br>
>> > 0.5)<br>
>> ><br>
>> > 2009/7/10 Peter Kukuča <<a href="mailto:pjr.kukuca@gmail.com">pjr.kukuca@gmail.com</a>>:<br>
>> >> Hi Pedro,<br>
>> >><br>
>> >> thank you for your reply.<br>
>> >><br>
>> >> I cannot use pointn, the line can be up to several hundred kilometers<br>
>> >> long<br>
>> >> and consits of up to 800 points, so this would be too rough.<br>
>> >><br>
>> >> Regardinf the decond suggestion, that is exactly what I am doing now,<br>
>> >> but I<br>
>> >> don't know, which projection (srid) to transform the wgs84 data into.<br>
>> >> It<br>
>> >> should work on all of the earth's surface, at least in all of europe<br>
>> >> for a<br>
>> >> start. And from what I found, the projections are usually tied to a<br>
>> >> small<br>
>> >> territory. I was thinking about mercator projection, but there is a<br>
>> >> zillion<br>
>> >> of them in postgis. And I found a post, that the one with srid 900913<br>
>> >> is<br>
>> >> working great, but I don't have that one in my postgis.<br>
>> >><br>
>> >> 2009/7/10 Pedro Doria Meunier <<a href="mailto:pdoria@netmadeira.com">pdoria@netmadeira.com</a>><br>
>> >>><br>
>> >>> -----BEGIN PGP SIGNED MESSAGE-----<br>
>> >>> Hash: SHA1<br>
>> >>><br>
>> >>> Hi Peter<br>
>> >>><br>
>> >>> You could use the pointn(geometry, n) for the first point of the<br>
>> >>> linestring as a first approach.<br>
>> >>> As far as meters are concerned here's a little example of transforming<br>
>> >>> the geometry to the desired projected system:<br>
>> >>><br>
>> >>> select distance(transform(u.coordinates,srid),<br>
>> >>> transform(p.geometry,srid)) AS thedistance<br>
>> >>><br>
>> >>> HTH,<br>
>> >>><br>
>> >>> Pedro Doria Meunier<br>
>> >>> GSM: +351 96 17 20 188<br>
>> >>> Skype: pdoriam<br>
>> >>><br>
>> >>><br>
>> >>><br>
>> >>><br>
>> >>> Peter Kukuča wrote:<br>
>> >>> > Dear sir,<br>
>> >>> ><br>
>> >>> > I am not sure if I am writing to the correct email address. I have<br>
>> >>> > found a post on the postgis-users formu from *Rich Gibson *and this<br>
>> >>> > address was next to it.<br>
>> >>> ><br>
>> >>> > I am using postgis for a while now and it is great. It solved a lot<br>
>> >>> > of problems for me.<br>
>> >>> ><br>
>> >>> > However, I am now facing a problem I cannot solve. I searched for<br>
>> >>> > almost two days now, but I still cannot find an answer. Here is my<br>
>> >>> > problem:<br>
>> >>> ><br>
>> >>> > I have a database of linestrings in wgs84 projection and points in<br>
>> >>> > wgs84 projection. I would like to determine the distance between a<br>
>> >>> > line and a point. The ST_distance function does this very well, but<br>
>> >>> > it does not take the wgs84 projection into account and also, the<br>
>> >>> > result is in degrees. On the other hand, the ST_Distance_Spheroid<br>
>> >>> > does take the wgs84 into accound and does give the result in meters,<br>
>> >>> > but it does not accept a linestring as an input parameter.<br>
>> >>> ><br>
>> >>> > Is there any way i can the distance between a line and a point in<br>
>> >>> > meters from the wgs84 projected input? I do not need grat accuracy.<br>
>> >>> > +-5 meters is still good enough. Thank you for your tips.<br>
>> >>> ><br>
>> >>> > --<br>
>> >>> > S pozdravom (regards)<br>
>> >>> > Ing. Peter Kukuča<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > ----------------------------------------------------------------------<br>
>> >>> ><br>
>> >>> > _______________________________________________<br>
>> >>> > postgis-users mailing list<br>
>> >>> > <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>> >>> > <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
>> >>> -----BEGIN PGP SIGNATURE-----<br>
>> >>> Version: GnuPG v1.4.7 (GNU/Linux)<br>
>> >>> Comment: Using GnuPG with Fedora - <a href="http://enigmail.mozdev.org" target="_blank">http://enigmail.mozdev.org</a><br>
>> >>><br>
>> >>> iD8DBQFKVv052FH5GXCfxAsRAqS1AJ0dfphFX3wrMuo+FdXVRTgmUzHRUACfUmvH<br>
>> >>> 146yGHfxoVmlnt9a91rpWmE=<br>
>> >>> =G70f<br>
>> >>> -----END PGP SIGNATURE-----<br>
>> >>><br>
>> >>> _______________________________________________<br>
>> >>> postgis-users mailing list<br>
>> >>> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>> >>> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
>> >><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> S pozdravom (regards)<br>
>> >> Ing. Peter Kukuča<br>
>> >><br>
>> >> _______________________________________________<br>
>> >> postgis-users mailing list<br>
>> >> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>> >> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
>> >><br>
>> >><br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > <a href="http://iap.md" target="_blank">http://iap.md</a>, The future is open<br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> <a href="http://iap.md" target="_blank">http://iap.md</a>, The future is open<br>
>> _______________________________________________<br>
>> postgis-users mailing list<br>
>> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
><br>
><br>
><br>
> --<br>
> S pozdravom (regards)<br>
> Ing. Peter Kukuča<br>
><br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
><br>
><br>
<br>
<br>
<br>
--<br>
<a href="http://iap.md" target="_blank">http://iap.md</a>, The future is open<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>S pozdravom (regards)<br>Ing. Peter Kukuča<br>