[gdal-dev] tps - gdalwarp vs ogr2ogr

Even Rouault even.rouault at spatialys.com
Tue Nov 7 04:48:50 PST 2023


Hi,

I've ticketed your issue as https://github.com/OSGeo/gdal/issues/8672 . 
What you could try to reduce the execution time is to enable 
multithreading by adding -wo NUM_THREADS=ALL_CPUS to your gdalwarp 
command line

And yes the previous implementation of the raster TPS transformation was 
"wrong", at least not consistent with the forward direction of the TPS 
transformer as used by ogr2ogr. Both matched on the exact location of 
ground control points, but the result could be substantially different 
in-between. The new implementation solves that, but it implies 
substantial more computation cost as you found out...

Even

Le 07/11/2023 à 08:29, Stijn Tallir via gdal-dev a écrit :
> Hi Jukka,
>
> The transformation lasted 3h20min vs 9min (before the fix)!
>
> The results for raster and vector tps transformation are very 
> similar now and nothing changed for the vector result. Do I have to 
> conclude the previous rasters tps transformation method was faulty then?
>
> Stijn
>
> Op ma 6 nov 2023 om 16:32 schreef Stijn Tallir 
> <stijn+gdal-dev at strict.be <mailto:stijn%2Bgdal-dev at strict.be>>:
>
>     Hi,
>
>     Does that mean the old raster tps transformation was "wrong" or
>     the old vector transformation?
>
>     I'm doing a test and trying to transform my raster image with the
>     latest dev version in osgeo4W but it takes forever to process now.
>     Don't know in how many days I will see the result :(
>
>     The vector transformation with the latest dev version was the same
>     (time and result).
>
>     Stijn
>
>     Op ma 6 nov 2023 om 14:48 schreef Rahkonen Jukka
>     <jukka.rahkonen at maanmittauslaitos.fi>:
>
>         Hi,
>
>         See the issue https://github.com/OSGeo/gdal/issues/8572
>         <https://github.com/OSGeo/gdal/issues/8572>. Maybe your
>         problem is also resolved by
>         https://github.com/OSGeo/gdal/pull/8573. The fix is included
>         in the GDAL 3.8 RC1 version that was released 3 hour ago. Do
>         you have an option to make a test?
>
>         -Jukka Rahkonen-
>
>         *Lähettäjä:* Stijn Tallir <stijn at strict.be>
>         *Lähetetty:* maanantai 6. marraskuuta 2023 14.47
>         *Vastaanottaja:* Rahkonen Jukka
>         <jukka.rahkonen at maanmittauslaitos.fi>
>         *Kopio:* gdal-dev at lists.osgeo.org
>         *Aihe:* Re: [gdal-dev] tps - gdalwarp vs ogr2ogr
>
>         Hi Jukka,
>
>         I finally found the time to produce a test set.
>
>         You can download it here:
>         https://drive.google.com/file/d/1Y08Q-tIm5dxyKFKNdVqilvAO3H7FFFbx/view?usp=sharing
>
>         I started from an unreferenced raster file (raster2tps.tif)
>         with gcp's (gcp4tps.gcp) and transformed it with tps
>         (tpsraster.tif).
>
>         Then polygonized the unreferenced raster file (vector2tps.shp)
>         and transformed the result with  the same gcp's (gcp4tps.gcp)
>         and with tps (tpsvector.shp).
>
>         The vector2tps.shp polygons are "flipped" because of the
>         different Y-origin for rasters and vectors but this way both
>         datasets can use the exact same gcp's.
>
>         When you lay the tpsvector-result on top of the
>         tpsraster-result (in QGis for instance) you'll see the
>         differences in how both are transformed.
>
>         Kind regards,
>
>         Stijn
>
>         Op wo 16 aug 2023 om 13:16 schreef Stijn Tallir
>         <stijn+gdal-dev at strict.be <mailto:stijn%2Bgdal-dev at strict.be>>:
>
>             Yes, I checked them visually for both raster and vector.
>
>             I compared the results also visually. The rasters are
>             transformed in a way that the end ponts of the gcp's align
>             exactly with the result so that is why I referred to it as
>             "right". The vector data result is in the neighbourhood of
>             the end points (sometimes a rather significant distance).
>
>             The result is different from order 1-3 transformations so
>             I presume the tps option isn't ignored.
>
>             Stijn
>
>             Op wo 16 aug 2023 om 11:52 schreef Rahkonen Jukka
>             <jukka.rahkonen at maanmittauslaitos.fi>:
>
>                 Hi,
>
>                 Did you check the ground control points? What is your
>                 reference when you say that one result is right, and
>                 another wrong? Have you used some other software for
>                 comparison? Or do you only know that the results are
>                 different?
>
>                 -Jukka-
>
>                 *Lähettäjä:* Stijn Tallir <stijn at strict.be>
>                 *Lähetetty:* keskiviikko 16. elokuuta 2023 12.27
>                 *Vastaanottaja:* Rahkonen Jukka
>                 <jukka.rahkonen at maanmittauslaitos.fi>
>                 *Kopio:* gdal-dev at lists.osgeo.org
>                 *Aihe:* Re: [gdal-dev] tps - gdalwarp vs ogr2ogr
>
>                 Hi Jukka,
>
>                 I thought of the density as an option for the "error"
>                 as you suggested and I made a point-file with a point
>                 for every pixel in my original image and used this as
>                 a source for the ogr2ogr transformation. So you could
>                 say the desnity for both sources raster and vector)
>                 are then alike.
>
>                 The results were still the same (and wrong) ...
>
>                 Stijn
>
>                 Op wo 16 aug 2023 om 10:22 schreef Rahkonen Jukka
>                 <jukka.rahkonen at maanmittauslaitos.fi>:
>
>                     Hi,
>
>                     Without test data it is very hard to say much. I
>                     believe that the promise of tps is that the ground
>                     control points stay where they are set. The
>                     intermediate points follow the least tension
>                     surfaces and I do not know how exactly those
>                     spline algorithms are defined. Raster data is full
>                     of points to warp but probably in the vector data
>                     the transformation is done vertex by vertex. I
>                     would first check if the GCPs are in the same
>                     place in both outputs. Then I would make a test by
>                     densifying the vector data before georeferencing
>                     to have much more vertices and see if it has any
>                     effect on the result.
>
>                     -Jukka Rahkonen-
>
>                     *Lähettäjä:* gdal-dev
>                     <gdal-dev-bounces at lists.osgeo.org> *Puolesta
>                     *Stijn Tallir
>                     *Lähetetty:* keskiviikko 16. elokuuta 2023 10.29
>                     *Vastaanottaja:* gdal-dev at lists.osgeo.org
>                     *Aihe:* [gdal-dev] tps - gdalwarp vs ogr2ogr
>
>                     Hi,
>
>                     According to the documentation gdal and ogr use
>                     the same algorithm for the tps-transformation but
>                     I don't seem to get the same results using the
>                     same set of gcp's for images and vectors.
>
>                     I have images that are unreferenced and vector
>                     data digitised on these images (in pixel coordinates).
>
>                     The images are then georeferenced with +100 gcp's
>                     and warped with gdalwarp using the "tps" option.
>
>                     When I use the same gcp's (with adjusted y-origin
>                     to lower left corner) to georeference the vector
>                     data with ogr2ogr and the "tps" option I get
>                     different results. The vector-result is similar to
>                     the image-result but never exactly the same and
>                     differences can be substantial.
>
>                     Any thoughts?
>
>                     Stijn
>
>
>                 -- 
>
>                 Stijn Tallir - StrICT BV
>
>                 Wijnveld 8
>
>                 9112 Sinaai-Waas
>
>                 GSM: 0486 750220
>
>                 E-mail: Info at strict.be
>
>                 Web: www.strict.be <http://www.strict.be/>
>
>                 BTW: BE 0567.559.668
>
>
>         -- 
>
>         Stijn Tallir - StrICT BV
>
>         Wijnveld 8
>
>         9112 Sinaai-Waas
>
>         GSM: 0486 750220
>
>         E-mail: Info at strict.be
>
>         Web: www.strict.be <http://www.strict.be/>
>
>         BTW: BE 0567.559.668
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20231107/94110d4b/attachment-0001.htm>


More information about the gdal-dev mailing list