# [postgis-users] how to use distances in kilometers in dwithin query?

Paragon Corporation lr at pcorp.us
Mon Feb 2 14:04:20 PST 2009

```Davi,

Okay you can do

ST_Dwithin(ST_Transform(the_geom, some_meter_srid), 3000)

Where 3000 is in meters.

Below utmzone function here might help to figure out the best srids for your
data

http://postgis.refractions.net/support/wiki/index.php?plpgsqlfunctions

If your data covers the whole world things are a bit trickier.

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Davi
Pires
Sent: Monday, February 02, 2009 4:08 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] how to use distances in kilometers in dwithin
query?

Sorry. All geometries are in SRID 4326.

Davi

On Mon, Feb 2, 2009 at 9:55 PM, Paragon Corporation <lr at pcorp.us> wrote:
> You can't.  It always uses the units of the spatial reference system
> your data is stored in.
>
> What spatial ref are you using?
>
> Leo
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> Davi Pires
> Sent: Monday, February 02, 2009 3:12 PM
> To: PostGIS Users Discussion
> Subject: [postgis-users] how to use distances in kilometers in dwithin
> query?
>
> Hi list,
>
> Regarding the st_dwithin(geometry, geometry, float) function, I would
> like to know how can I pass the distance argument in kilometers. In
> our tests we have been using a dummy value of 0.003, but we don't even
> know which units it is in.
>
> Davi Pires
>
> --
>
>
> eco-blog: http://tarjaverde.wordpress.com
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>

--

eco-blog: http://tarjaverde.wordpress.com
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

```