[postgis-users] wrong distance calculation

Igor Stassiy istassiy at gmail.com
Wed Mar 18 13:21:41 PDT 2015


you are using numeric(10, 2), which trims all except 2 decimal digits. that
will cause a huge error in calculations.

-Igor

On Wed, Mar 18, 2015 at 7:56 PM Ahmet Temiz <ahmettemiz88 at gmail.com> wrote:

> hello
>
> I am trying to calculate the distance from the schools to active faults
> and their lengths.
>  But then I tried to validate the some results and noticed that spatial
> query gave
> longer distances than checked values (in QGIS).
>
> I used this sql fragment:
>
>
> ~~~~~~~~~~~~~
> SELECT sOk.adi as adi,sFay.gid as faygid,sOk.gid as
> OkGid,sOk.bolgeno,sFay.fayadi,sOk.il,
>               sOk.ilce,sOk.jeo,
>               ST_Length(geography(sFay.the_geom))::numeric(10,2) as
> FayBoyu , sOk.the_geom as the_geom ,
>               ST_Distance(                                         *****
>               geography(sOk.the_geom),
>               geography(sFay.the_geom)
>               ) ::numeric(10,2) AS distance
>         FROM sOkul_DepZon as sOk
>         JOIN sdirifay_4326 as sFay
>         ON ST_DWithin(
>               geography(sOk.the_geom),
>               geography(sFay.the_geom),
>               120000) and  (sFay.faytipi~'1' or sFay.faytipi~'2')
>
>
>
> ~~~~~~~~~~~~~
>
> ​Can you tell me what the likely mistakes are ?
>
> Ahmet Temiz
>
> regards​
>
> --
> Ahmet Temiz
> Jeoloji Müh.
> Afet ve Acil Durum Yönetimi Başkanlığı
> Planlama ve Zarar Azaltma Dairesi Başkanlığı
>
>
> ________________________
>
> Ahmet Temiz
> Geological Eng.
> Information Systems - GIS Group
> Disaster and Emergency Management
> of Presidency
>  _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150318/7f03f139/attachment.html>


More information about the postgis-users mailing list