I have a database and I am using geoms to build polygons around points.

I need to do st_distance, st_area, st_overlaps, st_union, and st_instersects. also using st_x and st_y and st_project, so pretty sure i have to use geometry data type for these operations.

My issue is that I need meters, not degrees to get st_distance between points, and and st_area of polygons.

Should i do a cast with the :: operator to convert to geography or should i project?

Also, how do I choose which srid to pick?

My input could be anywhere in the US (including AL, HI).

  • agreeing with @robinloche; if you are constructing polygons based on distance and bearing, don't project, as 'ST_Project` naturally requires the input to be geography. use EPSG:4326 (geometry) and cast to geography for ST_Distance, ST_Area and ST_Project. btw., use_spheroid is the default and yields best precision.
    – geozelot
    May 11 '18 at 7:05

If your data is in 4326, I'm pretty sure you can just cast in ::geography (don't forget to set the boolean use_spheroid at the end of ST_Distance and ST_Area). The result of these functions, if you use a geography type, will be in meters.

If you want computation to be faster, you can either put use_spheroid to false (it will then use a sphere approximation) or to project it, like you said. I don't know much about US projection, but it's not that north so a good 3857 (web mercator) should be enough if a little approximation doesn't scare you (commonly used, depends of your precision needs: horizontal scale factor: 1/cos(latitude): What's the accuracy of Web Mercator EPSG:3857? )

  • 1
    just a note, though: I wouldn't advice to use EPSG:3857 for anything involving spatial analyses, despite the fact it might have tolerable distortions at the equator. maybe and only if your data setup points a gun to your head...
    – geozelot
    May 11 '18 at 7:14

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.