[GRASS-dev] Fwd: [gdal-dev] ogr2ogr clip operation very slow compared to QGIS

Markus Neteler neteler at osgeo.org
Tue Nov 13 15:19:14 PST 2018


FYI - not sure if relevant for us

---------- Forwarded message ---------
From: Nyall Dawson <nyall.dawson at gmail.com>
Date: Wed, Nov 14, 2018 at 12:17 AM
Subject: Re: [gdal-dev] ogr2ogr clip operation very slow compared to QGIS
To: Even Rouault <even.rouault at spatialys.com>
Cc: gdal dev <gdal-dev at lists.osgeo.org>

On Wed, 14 Nov 2018 at 01:03, Even Rouault <even.rouault at spatialys.com> wrote:

> Looking at QGIS code, it uses GEOS prepared geometry mechanism with the clip
> geometry, so as to speed up intersection operations on it. Whereas ogr2ogr -
> clipsrc uses the 'naive' intersection function. I guess this is the reason for
> the speed difference.

This is the big difference -- using the prepared methods results in
orders of magnitude speed boosts.

> QGIS also checks for the result of contains() and
> intersects() predicates before calculating the intersection geometry. Not sure
> how much that speed-up things.

Significantly (sorry no actual figures available). What's happening
here is the GEOS intersection method doesn't utilise prepared
geometries, yet the tests like contains and intersects do. The raw
intersection method is slow, even if there's no actual intersection or
if the geometry will be returned unchanged (i.e. it's within the clip
mask). So by taking advantage of the fast within/intersects tests on
the prepared geometry we potentially skip a bunch of unnecessary slow
intersection calculations.

Nyall
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the grass-dev mailing list