[postgis-users] Need help on basic concepts, I just need really simple calculations

Nicolas Ribot nicolas.ribot at gmail.com
Sun Mar 22 05:44:09 PDT 2015


Hi Aaron,

SRID is used to set a consistent coordinate system to the data. It refers
to an EPSG Coordinate Reference System (CRS). For instance, EPSG:2600: (
http://spatialreference.org/ref/epsg/2600/) is a metric CRS.

Coordinates (146.0, 138.19) are not valid in SRID 2600 (nor in lat/long
coordinates).

You would use st_setSRID when the coordinates are already in the correct
CRS, and st_transform() to reproject coordinates from one CRS to another:

-- Search inside a 100m circle for a point already in SRID=2600:
SELECT * FROM users
WHERE ST_DWithin (users.location, st_setsrid(st_makepoint (508560,
6155116), 2600), 100);

-- Search inside a 100m circle for a point in longitude/latitude, projected
into SRID=2600:
SELECT * FROM users
WHERE ST_DWithin (users.location, st_transform(st_setsrid(st_makepoint
(24.1 55.5), 4326), 2600), 100);

(users.location SRID should be 2600 in these examples)

Nicolas



On 22 March 2015 at 12:09, Aaron Lewis <the.warl0ck.1989 at gmail.com> wrote:

> Hi,
>
> I've been searching online for days. Trying to understand why SRID is
> required. So I picked some random value.
>
> Now I'm need to retrieve POINTs within a circle range, e.g a circle at
> (146.0, 138.19) with radius of 100 meters:
>
> SELECT * FROM users
> WHERE ST_DWithin (users.location, st_setsrid(st_makepoint (146.0,
> 138.19), 2600), 100);
>
> It's very simple, but the result seems wrong. I have a record contains
> a POINT(55 43) that matches this query.
>
> Anyone know what's wrong with it?
>
> --
> Best Regards,
> Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/
> Finger Print:   9F67 391B B770 8FF6 99DC  D92D 87F6 2602 1371 4D33
> _______________________________________________
> 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/20150322/b5a80a58/attachment.html>


More information about the postgis-users mailing list