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

qgis_process with algorithms using a CRS: error and a faulty message #57494

Closed
1 of 2 tasks
florisvdh opened this issue May 20, 2024 · 2 comments · Fixed by #57508
Closed
1 of 2 tasks

qgis_process with algorithms using a CRS: error and a faulty message #57494

florisvdh opened this issue May 20, 2024 · 2 comments · Fixed by #57508
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore

Comments

@florisvdh
Copy link
Contributor

What is the bug or the crash?

An error is reported while requesting help or while running an algorithm with a crs type argument.

  • For qgis_process help, the ERRORs only occur when the argument has a default value.
  • In qgis_process run:
    • the ERRORs come up
    • however the process does execute successfully
    • there's also a faulty message Using non-preferred coordinate operation between and EPSG:4326 (see example below). Note the irrelevant EPSG:4326 (it's probably taking that from the default value), since in the example the source and target CRS just use the OSGB_1936 datum.

Steps to reproduce the issue

$ qgis_process help native:reprojectlayer 1> /dev/null 
ERROR: Status 2: File EPSG:4326 could not be found
ERROR: Status 2: File EPSG:4326 could not be found
$ 
$ qgis_process help native:creategrid 1> /dev/null
ERROR: Status 2: File ProjectCrs could not be found
ERROR: Status 2: File ProjectCrs could not be found
$
$ # no default value here:
$ qgis_process help grass:v.proj 1> /dev/null
$ wget -q https://github.com/r-spatial/sf/raw/main/inst/gpkg/b_pump.gpkg
$ 
$ gdalsrsinfo b_pump.gpkg -o wkt2_2019 | head -3

PROJCRS["Transverse_Mercator",
    BASEGEOGCRS["GCS_OSGB 1936",
$ 
$ qgis_process run native:reprojectlayer --INPUT=b_pump.gpkg --TARGET_CRS='EPSG:4277' --OUTPUT=out.gpkg                

----------------
Inputs
----------------

INPUT:	b_pump.gpkg
OUTPUT:	out.gpkg
TARGET_CRS:	EPSG:4277


Using non-preferred coordinate operation between  and EPSG:4326. Using +proj=pipeline +step +inv +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +step +proj=push +v_3 +step +proj=cart +ellps=airy +step +proj=helmert +x=446.448 +y=-125.157 +z=542.06 +rx=0.15 +ry=0.247 +rz=0.842 +s=-20.489 +convention=position_vector +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg, preferred +proj=pipeline +step +inv +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +step +proj=hgridshift +grids=uk_os_OSTN15_NTv2_OSGBtoETRS.tif +step +proj=unitconvert +xy_in=rad +xy_out=deg.
ERROR: Status 2: File EPSG:4277 could not be found
ERROR: Status 2: File EPSG:4277 could not be found

----------------
Results
----------------

OUTPUT:	out.gpkg
$ 
$ ls out.gpkg
out.gpkg
$ 
$ gdalsrsinfo out.gpkg -o wkt2_2019 | head -3

GEOGCRS["OSGB36",
    DATUM["Ordnance Survey of Great Britain 1936",

Versions

$ qgis_process --version
QGIS 3.36.3-Maidenhead 'Maidenhead' (2df9655469b)
QGIS code revision 2df9655469b
Qt version 5.15.3
Python version 3.10.12
GDAL/OGR version 3.8.4
PROJ version 9.3.1
EPSG Registry database version v10.098 (2023-11-24)
GEOS version 3.12.1-CAPI-1.18.1
SQLite version 3.37.2
OS Linux Mint 21.3

Supported QGIS version

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

New profile

Additional context

No response

@florisvdh florisvdh added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 20, 2024
@agiudiceandrea agiudiceandrea added Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore labels May 21, 2024
@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented May 21, 2024

At least the "ERROR: Status 2: File ... could not be found " issue didn't occur using QGIS 3.28.

It seems to me the error message is caused by p->valueAsString( p->defaultValue(), context, ok ) when the following line in QgsProcessingExec::showAlgorithmHelp is executed:

std::cout << QStringLiteral( "\tDefault value:\t%1\n" ).arg( p->valueAsString( p->defaultValue(), context, ok ) ).toLocal8Bit().constData();

In fact, when the following code is executed in the Python console of QGIS 3.34 or QGIS 3.36:

context = QgsProcessingContext()
alg = QgsApplication.processingRegistry().algorithmById( "native:reprojectlayer" )
defs = alg.parameterDefinitions()
p = defs[1]
p.valueAsString( p.defaultValue(), context)

the output is ('EPSG:4326', True) and the following error is displayed in the OGR tab of the Log Messages Panel:
WARNING Cannot open EPSG:4326 ().()
The same warning is displayed even just opening the algorithm dialog window.

@nyalldawson
Copy link
Collaborator

Hmm, this sounds a little like the issue addressed by #56292

Maybe a similar cause for this one..

@nyalldawson nyalldawson self-assigned this May 22, 2024
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue May 22, 2024
...before falling back to alternatives like treating it as a map
layer

Fixes qgis#57494
nyalldawson added a commit that referenced this issue May 23, 2024
...before falling back to alternatives like treating it as a map
layer

Fixes #57494
qgis-bot pushed a commit that referenced this issue May 23, 2024
...before falling back to alternatives like treating it as a map
layer

Fixes #57494
nyalldawson added a commit that referenced this issue May 23, 2024
...before falling back to alternatives like treating it as a map
layer

Fixes #57494
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue May 27, 2024
And fix tests which use an invalid EPSG code

Refs qgis#57494
nyalldawson added a commit that referenced this issue May 27, 2024
And fix tests which use an invalid EPSG code

Refs #57494
qgis-bot pushed a commit that referenced this issue May 27, 2024
And fix tests which use an invalid EPSG code

Refs #57494
nyalldawson added a commit that referenced this issue Jun 19, 2024
And fix tests which use an invalid EPSG code

Refs #57494
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! Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants