PostGIS Geometry vs Geography: What is the Real Difference?

🧠 Question (by MapMaker88):
"What's the real difference between the geometry and geography types in PostGIS?"

 

✅ Answer (by Admin):
Great question! Both geometry and geography In PostGIS, spatial data is stored, but it handles coordinate systems differently:

  • Geometry treats coordinates as points on a flat Cartesian plane. It’s faster, ideal for small areas, and uses units like meters or feet based on the projection.

    Example:

    SELECT ST_Distance(geometry1, geometry2);
  • Geography assumes the Earth is a sphere (WGS 84) and calculates great-circle distances over curved surfaces — ideal for achieving global-scale accuracy.

    Example:

    SELECT ST_Distance(geography1, geography2);

💡 Bonus Tip:
Use geometry for city-level maps or local analysis. Use geography When working with global datasets or cross-country distances.

Comments

Leave a Reply