[OSM-dev] Area calculation without transformation

Florian Lohoff f at zz.de
Sun Mar 24 22:03:53 UTC 2024


On Sun, Mar 24, 2024 at 10:28:17PM +0100, Even Rouault wrote:
> Hi,
> 
> if you use GDAL, you have already the PROJ dependency. So if you install
> PROJ development headers and include "geodesic.h" and use the
> geod_polygonarea() function, or geod_polygon_compute(), which is what
> PostGIS uses under the hood to implement ST_Area() on spheroid at https://github.com/postgis/postgis/blob/c25c64341c5a31ecb0bbcd17740bb000bd9cf759/liblwgeom/lwspheroid.c#L142
> 
> An alternative is to use Spatialite's ST_Area(surface_geom,
> /*use_ellipsoid=*/1) function, but that requires libspatialite to have been
> built against librttopo, which isn't a common setup.
> 
> Seeing all that, I've just queued enhancements in GDAL related to all the
> above: https://github.com/OSGeo/gdal/pull/9552

I found the performance issue by looking at valgrinds callgrind output.

Using geom->transformTo is a real hard performance hit as it seems it
imports/creates the source reference system on every single call. (I
created the target SRS once and reused it).

So changing to using OGRCreateCoordinateTransformation once and then
using geom->transform(OGRCoordinateTransformation) is a lot faster.

My complete analysis is running in 2 instead of 60+ minutes.

Flo
-- 
Florian Lohoff                                                     f at zz.de
  Any sufficiently advanced technology is indistinguishable from magic.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20240324/0054472c/attachment.sig>


More information about the dev mailing list