4

I'm trying to perform some spatial relationship analysis using Postgis functions like st_dwithin and st_dfullywithin. I searched and found that for any SRID, using the geography type gives the results in metres which works well for st_dwithin. However, the st_dfullywithin the arguments need to be of type geometry so this approach does not work.

My base SRID is 4283 and I've tried transforming the SRID of the geometry objects to SRID 3577 which still does not work.

As a test, I tried to measure the distance between two points using different SRID and the geometry and geography types. I believe the units of 3577 is in metres, but when I run the test to get the distance between two points using SRID 3577 it returns the results in degrees, but changing the type to geography returns metres.

I thought changing the SRID to one with metres should return metres? If not, how can you work in metres?

EDIT: The query to get the distance which gives the result in degrees is,

select st_distance(st_geomfromtext('POINT(150.9319747 -33.8482439)', 3557), st_geomfromtext('POINT(151.9319747 -34.8482439)', 3557))

If I use the same SRID, I have to use the following query to get the result in metres

select st_distance(st_geomfromtext('POINT(150.9319747 -33.8482439)', 3557)::geography, st_geomfromtext('POINT(151.9319747 -34.8482439)', 3557)::geography)

My ultimate aim is to fine geoms that are within a given radius of a point,

select 
*
from table_1 a
where ST_DWithin(st_transform(a.geom, 3557), st_transform(st_geomfromtext('POINT(150.9319747 -33.8482439)', 4283),3557), 50000);

Inspite of using the different SRIDs, the relationship still considers degrees and not meters.

1
  • 1
    Show the query please.
    – kttii
    Commented Nov 28, 2016 at 2:44

1 Answer 1

4

Your query:

select st_distance(st_geomfromtext('POINT(150.9319747 -33.8482439)', 3557), st_geomfromtext('POINT(151.9319747 -34.8482439)', 3557))

is not transforming the geometry. You are just telling PostGIS that your coordinates are in SRID 3557.

If you want to transform the geometry, you need:

SELECT ST_Distance(ST_Transform(ST_GeomFromText('POINT(150.9319747 -33.8482439)', 4326),3557), ST_Transform(ST_GeomFromText('POINT(151.9319747 -34.8482439)', 4326), 3557))

However, your points are out of bounds for projection 3557. Try 3857 (Web Mercator), or another projection that is better suited for your area of interest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.