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: impossible to execute some algorithms for lack of project context #37988

Closed
agiudiceandrea opened this issue Jul 27, 2020 · 0 comments · Fixed by #37992
Closed
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

Comments

@agiudiceandrea
Copy link
Contributor

Describe the bug

Some algorithms need information stored in the project properties, like ellipsoid to use, or crs of the project, area and length measurement units, in order to properly execute the job.

It seems impossible to run those algs using qgis_process because it is not possible to specify a project containing the needed information nor to provide the necessary information directly passing them as additional parameters.

A probably not comprehensive list of algorithms that use context.project() follows:

qgis:exportaddgeometrycolumns (only methods 1 e 2)
qgis:fieldcalculator
qgis:distancetonearesthublinetohub
qgis:distancetonearesthubpoints
qgis:distancematrix
qgis:pointstopath
qgis:randompointsalongline
qgis:randompointsinsidepolygons
qgis:executesql
qgis:rastercalculator
qgis:postgisexecuteandloadsql
qgis:tilesxyzdirectory

native:antimeridiansplit
native:sumlinelengths
native:calculatevectoroverlaps
native:nearestneighbouranalysis
native:refactorfields
native:linedensity
native:aggregate
native:hublines
native:categorizeusingstyle
native:networkanalysis
native:rasterize
native:loadlayer
native:setprojectvariable
native:stylefromproject
native:bookmarkstolayer

How to Reproduce

qgis_process run qgis:randompointsinsidepolygons --STRATEGY=0 --VALUE=1000 --INPUT="./ProvCM01012020_g/ProvCM01012020_g_WGS84.shp" --OUTPUT="./output/random_point_prov.shp"

/usr/lib/python3/dist-packages/qgis/utils.py:743: DeprecationWarning: the
imp module is deprecated in favour of importlib; see the module's
documentation for alternative uses
  mod = _builtin_import(name, globals, locals, fromlist, level)
Problem with SAGA installation: SAGA was not found or is not correctly
installed
----------------
Inputs
----------------

INPUT:  ./ProvCM01012020_g/ProvCM01012020_g_WGS84.shp
OUTPUT: ./output/random_point_prov.shp
STRATEGY:       0
VALUE:  1000

Logged critical: Traceback (most recent call last):
  File
"/usr/share/qgis/python/plugins/processing/algs/qgis/RandomPointsPolygons.py",
line 160, in processAlgorithm
    da.setEllipsoid(context.project().ellipsoid())
AttributeError: 'NoneType' object has no attribute 'ellipsoid'

Traceback (most recent call last):
  File
"/usr/share/qgis/python/plugins/processing/algs/qgis/RandomPointsPolygons.py",
line 160, in processAlgorithm
    da.setEllipsoid(context.project().ellipsoid())
AttributeError: 'NoneType' object has no attribute 'ellipsoid'
ERROR:  Traceback (most recent call last):
  File
"/usr/share/qgis/python/plugins/processing/algs/qgis/RandomPointsPolygons.py",
line 160, in processAlgorithm
    da.setEllipsoid(context.project().ellipsoid())
AttributeError: 'NoneType' object has no attribute 'ellipsoid'

QGIS and OS versions

QGIS 3.14.1

Additional context

Ref: #34617

@agiudiceandrea agiudiceandrea added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jul 27, 2020
@slarosa slarosa added the Processing Relating to QGIS Processing framework or individual Processing algorithms label Jul 27, 2020
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Jul 28, 2020
…ocessingContext

to avoid having to always retrieve these via the context's project (which may
not be available in some circumstances)

Refs qgis#37988
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Jul 28, 2020
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Jul 28, 2020
when running qgis_process

Appending "--ELLIPSOID=xxxx" to the argument list allows users to explicitly
set the ellipsoid to use for calculations.

Fixes qgis#37988
nyalldawson added a commit that referenced this issue Jul 29, 2020
…ocessingContext

to avoid having to always retrieve these via the context's project (which may
not be available in some circumstances)

Refs #37988
nyalldawson added a commit that referenced this issue Jul 29, 2020
when running qgis_process

Appending "--ELLIPSOID=xxxx" to the argument list allows users to explicitly
set the ellipsoid to use for calculations.

Fixes #37988
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants