2

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?

picardo
  • 248
  • 2
  • 9
  • 3
    I suspect they're the same, just one is in square meters and the other is in square degrees. See http://gis.stackexchange.com/questions/6681/ – Chris W Mar 17 '15 at 22:51

1 Answers1

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.

Regina Obe
  • 10,503
  • 1
  • 23
  • 28