1

I have a Geo table with geometry column storing point data SRD=4326

I need to find all points within a given distance in meters of a Longitude, Latitude

Do I create a geography column from the geometry column or the Longitude, Latitude stored in the table

or

Do the conversion on the fly within the query

Could someone suggest how to perform both options and there pro & cons?

1

You can do it both ways, storing geography or storing geometry and convert on the fly. If you create a geom column not based on SRID 4326, you can convert it to a geography type before the computation as follows (using the ST_DWithin function)

SELECT geom FROM my_points WHERE ST_DWithin(geom::geography, my_latlon);

Of course, this second approach is slower in use because of the need to cast geom to geography type.

  • 1
    FYI run both got same answer thanx – Holly Aug 24 '17 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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