Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid projection factors for PROJ test case (EPSG:5972) #58249

Open
2 tasks done
kannes opened this issue Jul 25, 2024 · 13 comments
Open
2 tasks done

Invalid projection factors for PROJ test case (EPSG:5972) #58249

kannes opened this issue Jul 25, 2024 · 13 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Linux Packaging Projections/Transformations Related to coordinate reference systems or coordinate transformation

Comments

@kannes
Copy link
Contributor

kannes commented Jul 25, 2024

What is the bug or the crash?

Trying to debug a work-in-progress plugin of mine for projection factor visualisation I found some issues with https://qgis.org/pyqgis/master/core/QgsCoordinateReferenceSystem.html#qgis.core.QgsCoordinateReferenceSystem.factors

Trying to replicate the last test case (for EPSG:5972) from /~https://github.com/OSGeo/PROJ/blob/7d766a4ba112ec71c9e861c66d571cbdddd71009/test/cli/test_proj.yaml#L18-L21 I get an invalid result instead of the values in PROJ's test case.

The test case above those lines (for EPSG:27571) works fine.

Steps to reproduce the issue

>>> crs = QgsCoordinateReferenceSystem.fromEpsgId(5972)
>>> crs.factors(QgsPoint(9, 0))
<QgsProjectionFactors: invalid>
>>> crs.factors(QgsPoint(0, 9))  # is it an axes inversion issue?
<QgsProjectionFactors: invalid>  # nope

Versions

<style type="text/css"> p, li { white-space: pre-wrap; } </style>
QGIS version 3.38.0-Grenoble QGIS code branch Release 3.38
Qt version 5.15.14
Python version 3.12.4
GDAL/OGR version 3.9.0
PROJ version 9.4.1
EPSG Registry database version v11.006 (2024-03-13)
GEOS version 3.12.2-CAPI-1.18.2
SQLite version 3.46.0
Compiled against PDAL 2.7.1 Running against PDAL 2.7.2
PostgreSQL client version 16.2
SpatiaLite version 5.1.0
QWT version 6.3.0
QScintilla2 version 2.14.1
OS version Arch Linux
       

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

Example value from the other, working test case:

QgsCoordinateReferenceSystem.fromEpsgId(27571).factors(QgsPoint(2.33722917, 49.5)).meridionalScale() -> 0.9998773409826835, which matches the test cases 0.999877

@kannes kannes added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jul 25, 2024
@kannes kannes changed the title Invalid projection factors for PROJ test case Invalid projection factors for PROJ test case (EPSG:5972) Jul 25, 2024
@kannes
Copy link
Contributor Author

kannes commented Jul 25, 2024

Running proj on the command line for those coordinates in that CRS also works on my system and provides the wanted values:

$ echo "9 0" | proj -V EPSG:5972
#Universal Transverse Mercator (UTM)
#	Cyl, Ell
#	zone= south approx
# +proj=utm +zone=32 +ellps=GRS80
#Final Earth figure: ellipsoid
#  Major axis (a): 6378137.000
#  1/flattening: 298.257222
#  squared eccentricity: 0.006694380023
Longitude: 9dE [ 9 ]
Latitude:  0dN [ 0 ]
Easting (x):   500000.00
Northing (y):  0.00
Meridian scale (h) : 0.99960000  ( -0.04 % error )
Parallel scale (k) : 0.99960000  ( -0.04 % error )
Areal scale (s):     0.99920016  ( -0.07998 % error )
Angular distortion (w): 0.000
Meridian/Parallel angle: 90.00000
Convergence : 0d [ -0.00000000 ]
Max-min (Tissot axis a-b) scale error: 0.99960 0.99960

@agiudiceandrea
Copy link
Contributor

@kannes, I cannot replicate the issue on my Windows 10 system using QGIS 3.38.0 [PROJ 9.4.0 / EPSG Registry database version v11.004 (2024-02-24)]:

crs = QgsCoordinateReferenceSystem.fromEpsgId(5972)
crs.factors(QgsPoint(9, 0))
<QgsProjectionFactors>
crs.factors(QgsPoint(9, 0)).isValid()
True
crs.factors(QgsPoint(9, 0)).meridionalScale()
0.9996000000506514

@kannes
Copy link
Contributor Author

kannes commented Jul 26, 2024

Huh, interesting! I cannot reproduce the issue on other systems as well:

QGIS version 3.34.6-Prizren QGIS code branch Release 3.34
Qt version 5.15.8
Python version 3.12.3
GDAL/OGR version 3.8.5
PROJ version 9.4.0
EPSG Registry database version v11.004 (2024-02-24)
GEOS version 3.12.1-CAPI-1.18.1
Compiled against SQLite 3.45.3 Running against SQLite 3.46.0
PDAL version 2.7.1
PostgreSQL client version unknown
SpatiaLite version 5.1.0
QWT version 6.2.0
QScintilla2 version 2.14.1
OS version Manjaro Linux
QGIS version 3.22.16-Białowieża QGIS code branch Release 3.22
Qt version 5.15.8
Python version 3.11.0
Compiled against GDAL/OGR 3.6.2 Running against GDAL/OGR 3.6.3
PROJ version 9.1.1
EPSG Registry database version v10.076 (2022-08-31)
GEOS version 3.11.1-CAPI-1.17.1
Compiled against SQLite 3.40.0 Running against SQLite 3.44.2
Compiled against PDAL 2.5.0 Running against PDAL 2.5.2
PostgreSQL client version 15.1
SpatiaLite version 5.0.1
QWT version 6.2.0
QScintilla2 version 2.13.4
OS version Manjaro Linux

Both get a valid QgsProjectionFactors result.

The main difference is Proj 9.4.0 vs 9.4.1.

@kannes
Copy link
Contributor Author

kannes commented Jul 26, 2024

Another one does have the same issue:

QGIS-Version 3.38.0-Grenoble QGIS-Codezweig Release 3.38
Qt-Version 5.15.14
Python-Version 3.12.4
GDAL-Version 3.9.0
PROJ-Version 9.4.1
EPSG-Registraturdatenbankversion v11.006 (2024-03-13)
GEOS-Version 3.12.2-CAPI-1.18.2
SQLite-Version 3.46.0
Gegen PDAL kompiliert 2.7.1 Läuft mit PDAL 2.7.2
PostgreSQL-Client-Version 16.2
SpatiaLite-Version 5.1.0
QWT-Version 6.3.0
QScintilla2-Version 2.14.1
BS-Version Manjaro Linux

Again, Proj 9.4.1

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jul 26, 2024

@kannes, I've also tried using PROJ 9.4.1 [proj_9_4.dll and proj.db from anaconda] with QGIS 3.38.1 [from OSGeo4W]

image

and I have the same output in the Python console

crs = QgsCoordinateReferenceSystem.fromEpsgId(5972)
crs.factors(QgsPoint(9, 0))
<QgsProjectionFactors>
crs.factors(QgsPoint(9, 0)).isValid()
True
crs.factors(QgsPoint(9, 0)).meridionalScale()
0.9996000000506514

No issue also using both QGIS 3.38.1 and PROJ 9.4.1 from conda-forge with on Windows 11.

@agiudiceandrea
Copy link
Contributor

Have you also tried QGIS from Flatpak and Spack? I think they have both PROJ 9.4.1.

@jjimenezshaw
Copy link
Contributor

With this verision is working for me:

<style type="text/css"> p, li { white-space: pre-wrap; } </style>
QGIS version 3.36.3-Maidenhead QGIS code branch Release 3.36
Qt version 5.15.8
Python version 3.12.3
GDAL/OGR version 3.9.0
Compiled against PROJ 9.4.0 Running against PROJ 9.4.1
EPSG Registry database version v11.006 (2024-03-13)
GEOS version 3.12.1-CAPI-1.18.1
SQLite version 3.46.0
PDAL version 2.7.1
PostgreSQL client version unknown
SpatiaLite version 5.1.0
QWT version 6.3.0
QScintilla2 version 2.14.1
OS version Ubuntu 22.04.4 LTS
       
Active Python plugins
qgis_points2one 0.3.1
reloader 0.1
FreehandRasterGeoreferencer 0.8.3
tiss 2.0.2
valuetool 3.0.19
qgis2web 3.21.0
db_manager 0.1.20
processing 2.12.99
grassprovider 2.12.99
MetaSearch 0.3.6
crs = QgsCoordinateReferenceSystem.fromEpsgId(5972)
crs.factors(QgsPoint(9, 0)).isValid()
True

... and after updating conda as well

<style type="text/css"> p, li { white-space: pre-wrap; } </style>
QGIS version 3.38.1-Grenoble QGIS code branch Release 3.38
Qt version 5.15.8
Compiled against Python 3.12.4 Running against Python 3.12.3
GDAL/OGR version 3.9.1
PROJ version 9.4.1
EPSG Registry database version v11.006 (2024-03-13)
GEOS version 3.12.2-CAPI-1.18.2
SQLite version 3.46.0
PDAL version 2.7.2
PostgreSQL client version unknown
SpatiaLite version 5.1.0
QWT version 6.3.0
QScintilla2 version 2.14.1
OS version Ubuntu 22.04.4 LTS
       
Active Python plugins
qgis_points2one 0.3.1
reloader 0.1
FreehandRasterGeoreferencer 0.8.3
tiss 2.0.2
valuetool 3.0.19
qgis2web 3.21.0
db_manager 0.1.20
processing 2.12.99
grassprovider 2.12.99
MetaSearch 0.3.6

@jjimenezshaw
Copy link
Contributor

That CRS is a compound one https://spatialreference.org/ref/epsg/5972/
Have you tried with the horizontal component? https://spatialreference.org/ref/epsg/25832/
The vertical component is not giving anything there.

@jjimenezshaw
Copy link
Contributor

That CRS is a compound one https://spatialreference.org/ref/epsg/5972/ Have you tried with the horizontal component? https://spatialreference.org/ref/epsg/25832/ The vertical component is not giving anything there.

Now I remember that support for compound CRSs was added later: OSGeo/PROJ@6f9fd55
In PROJ 9.4.0 (PR OSGeo/PROJ#3949)

@agiudiceandrea agiudiceandrea added Packaging Projections/Transformations Related to coordinate reference systems or coordinate transformation Linux labels Jul 26, 2024
@kannes
Copy link
Contributor Author

kannes commented Jul 26, 2024

25832 seems to work fine in my tests but I wanted to use external, definitely-correct data to validate if my plugin does things correctly.

Is QGIS not able to handle such compound CRS correctly maybe?

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jul 26, 2024

Is QGIS not able to handle such compound CRS correctly maybe?

I don't think so. On my Windows 10 / Windows 11 systems (either using both QGIS 3.38.0 and PROJ 9.4.0 from OSGeo4W or QGIS 3.38.1 from OSGeo4W and PROJ 9.4.1 from conda or both QGIS 3.38.1 and PROJ 9.4.1 from conda) and on Ubuntu 22.04 (using QGIS 3.3.8.1 and PROJ 9.4.1 from conda as reported by @jjimenezshaw) the issue doesn't occur.

@jjimenezshaw
Copy link
Contributor

Is QGIS not able to handle such compound CRS correctly maybe?

It is working for other people. I think it is a problem in your QGIS, maybe using a different installed version of PROJ (due to any unknown reason). Maybe you can check in your linux exactly what libproj.so is opening your QGIS (not an ldd, but the actual file opened at runtime) with something like

grep proj /proc/<qgis pid>/maps

@kannes
Copy link
Contributor Author

kannes commented Jul 26, 2024

Sorry, totally posted in a hurry and missed the 3.38 + 9.4.1 combos working.

Testing on the Manjaro one

The proj binary works fine. QGIS does not. Both use the same /usr/lib/libproj.so.25.9.4.1.
A conda QGIS 3.38.1 with Proj 9.4.1 on the same system works.

QGIS

crs = QgsCoordinateReferenceSystem.fromEpsgId(5972)
crs.factors(QgsPoint(9, 0))
<QgsProjectionFactors: invalid>
# grep proj /proc/$(pidof qgis)/maps
7f7d9c400000-7f7d9c44c000 r--p 00000000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1
7f7d9c44c000-7f7d9c765000 r-xp 0004c000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1
7f7d9c765000-7f7d9c803000 r--p 00365000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1
7f7d9c803000-7f7d9c81f000 r--p 00403000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1
7f7d9c81f000-7f7d9c820000 rw-p 0041f000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1

proj (entered 9 0 interactively)

proj -V EPSG:5972
#Universal Transverse Mercator (UTM)
#       Cyl, Ell
#       zone= south approx
# +proj=utm +zone=32 +ellps=GRS80
#Final Earth figure: ellipsoid
#  Major axis (a): 6378137.000
#  1/flattening: 298.257222
#  squared eccentricity: 0.006694380023
9 0
Longitude: 9dE [ 9 ]
Latitude:  0dN [ 0 ]
Easting (x):   500000.00
Northing (y):  0.00
Meridian scale (h) : 0.99960000  ( -0.04 % error )
Parallel scale (k) : 0.99960000  ( -0.04 % error )
Areal scale (s):     0.99920016  ( -0.07998 % error )
Angular distortion (w): 0.000
Meridian/Parallel angle: 90.00000
Convergence : 0d [ -0.00000000 ]
Max-min (Tissot axis a-b) scale error: 0.99960 0.99960
grep proj /proc/$(pidof proj)/maps
55b7d4b8b000-55b7d4b8d000 r--p 00000000 00:1a 6442960                    /usr/bin/proj
55b7d4b8d000-55b7d4b91000 r-xp 00002000 00:1a 6442960                    /usr/bin/proj
55b7d4b91000-55b7d4b93000 r--p 00006000 00:1a 6442960                    /usr/bin/proj
55b7d4b93000-55b7d4b94000 r--p 00008000 00:1a 6442960                    /usr/bin/proj
55b7d4b94000-55b7d4b95000 rw-p 00009000 00:1a 6442960                    /usr/bin/proj
7fab96c00000-7fab96c4c000 r--p 00000000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1
7fab96c4c000-7fab96f65000 r-xp 0004c000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1
7fab96f65000-7fab97003000 r--p 00365000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1
7fab97003000-7fab9701f000 r--p 00403000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1
7fab9701f000-7fab97020000 rw-p 0041f000 00:1a 6442992                    /usr/lib/libproj.so.25.9.4.1

conda create --name qgis_3.38.1 qgis=3.38.1 && conda activate

crs = QgsCoordinateReferenceSystem.fromEpsgId(5972)
crs.factors(QgsPoint(9, 0))
<QgsProjectionFactors>
crs.factors(QgsPoint(9, 0)).isValid()
True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Linux Packaging Projections/Transformations Related to coordinate reference systems or coordinate transformation
Projects
None yet
Development

No branches or pull requests

3 participants