I have a global coastline grid made up of polygons (hexagons) and I am trying to aggregate global data onto these hexagons. For example, I am trying to compute the distance of each hexagon to the nearest coral reef (also defined as a polygon). Since I use global datasets, which are quite large, I am using GeoPandas sjoin_nearest() function (both datasets are geodataframes), which links each hexagon to the nearest coral polygon (typically the distance will be in not be more than a few hundred km).

Do the distances that GeoPandas uses for this actually make sense? The CRS I am using for both datasets is EPSG:6933, which is an ellipsoidal, equal area projection with unit meters. However, the documentation of sjoin_nearest states that "Since this join relies on distances, results will be inaccurate if your geometries are in a geographic CRS. Every operation in GeoPandas is planar, i.e. the potential third dimension is not taken into account."

Does this mean I cannot use sjoin_nearest at all for geographic calculations, even with an area-preserving projection? And if not, does someone know a better way to do this?

I know that I will never get perfectly accurate distances, but I only need an accuracy in the order of 10km. Also, the analysis is limited to between 47.5 and -37.5 degrees latitude, so relatively far from the poles.

  • Distance measurements on a global scale are always wrong, whatever CRS you use: No projection can preserve distances but only for a small part of the map - be it along a line or only for distances from one (or two, using Two-point equidistant projection) points to all other points on the map. See here for details: gis.stackexchange.com/a/434196/88814
    – Babel
    Commented Aug 9, 2022 at 13:26
  • A rough approximation is to use ellipsoidal distances (Great-circle distance), that should be good enought for your use case.
    – Babel
    Commented Aug 9, 2022 at 13:27
  • I know that there is no distance preserving projection, but I'm mainly wondering if the error is acceptable for my purpose (O(10km)). But I guess it also depends on which distance and where on Earth. The problem is that using other distance functions take more computational effort, whereas the GeoPandas sjoin_nearest function is very quick, but only does planar. Commented Aug 9, 2022 at 16:53
  • This may or may not work, but I think it will work under your conditions: Use a conformal projection to find the nearest. Then, if needed, compute the ellipsoidal distance between both geometries using a geodetic library. Commented Aug 10, 2022 at 2:31

1 Answer 1


In order to calculate a meaningful distance, we must treat geographic coordinates not as approximate Cartesian coordinates but rather as true spherical coordinates. We must measure the distances between points as true paths over a sphere.

So we should use geographic types instead of geometric, that are planar and don't take into account earth's curvature (inaccurate distances), so for your task is better PostgreSQL/PostGIS geography type and functions


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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