1

I have this simple query that returns very different values for a geom vs a geog:

SELECT ST_Area(the_geom::geography) as area1, st_area(the_geom) from neighborhood where city_id='ny-new-york-city'

+----------------+--------------------+
|area1           | area               | 
+----------------+--------------------+
|1646766.08995329| 0.00017589982948304|
+----------------+--------------------+

The SRID of the_geom column is 4326. I don't get why geog column makes such a difference.

Which measurement is correct?

5

Geography uses a spheroidal model and always measures in meters though coordinates are expressed in degrees. Geometry is a planar model always even if you store your data in long lat coordinates (in that case your longitude is projected to X and latitude to Y -- what is known as a Platte-Carree projection. As such don't rely on measurement functions in geometry for long/lat data. Use a measure preserving spatial ref sys like one of the UTM ones, or use geography if you don't have the time to learn about spatial reference systems.

The downside is speed of geography is slower than geometry and has much fewer functions, the upside is you don't need to care about where you are in the world to use it.

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.