-
Notifications
You must be signed in to change notification settings - Fork 19
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
Ignore invalid geometries #11
Comments
Could you please provide a reproducible example? Otherwise it is hard to tell what possibly went wrong. |
Here is a reproducible example: set_env() Here is a link for the files used in the example: https://we.tl/t-hIFKmqEi94 I already know the issue is that the INPUT file has invalid geometries, but in QGIS this can be ignored and clipping can be done. So my question is more about whether this can also be ignored in RQGIS3? Info of the session R v. 3.6.0 (2019-04-26) |
A reproducible example should not make use of a file which is of size 1.5GB. Looking at the available parameters of |
Sorry I could not send another file, that is the only one I am using that has invalid geometries (I tried looking for alternative files online but I couldn't find any with invalid geometries). In QGIS you do Settings -> Options -> Processing tab, expand out the General setting -> Invalid feature filtering -> Ignore features with invalid geometries. I'll try with grass from RQGIS3, but I have already tried cleaning the geometries directly with grass before and it didn't work (the file has a lot of them) so I have to find ways to work with these invalid geometries. |
Ah ok, thanks for reporting back. I will have a look at how one can use invalid geometries using the Python API. |
I have found an answer how to use invalid geometries using the QGIS3 Python API, see here. However, I have not tested it. library("RQGIS3")
alg = "native:clip"
# construct a parameter-argument list using get_args_man and user input
params = get_args_man(alg = alg)
# PLEASE SPECIFY YOUR PARAMETERS!!!
params$INPUT = ""
params$OVERLAY = ""
params$OUTPUT = ""
# convert R parameter-argument list into a Python dictionary
params = r_to_py(params)
# accept invalid geometries
# Python syntax
# context = dataobjects.createContext()
# context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
# and doing the same with reticulate
context = py$processing$tools$dataobjects$createContext()
context$setInvalidGeometryCheck(py$QgsFeatureRequest$GeometryNoCheck)
# run QGIS
msg = py_capture_output(expr = {
res =
py$processing$run(algOrName = alg, parameters = params,
feedback = py$QgsProcessingFeedback(), context = context)
}) If it works we can think about implementing it in RQGIS3. |
Hi, I have been running the clip command from QGIS in R using RQGIS3 package. Everything goes fine except when I use as the input layer a vector with some invalid geometries. QGIS can be set to ignore such invalid geometries and still perform the clipping (or any other action) but in RQGIS3 I get the following error:
Error in py_call_impl(callable, dots$args, dots$keywords) :
QgsProcessingException: There were errors executing the algorithm.
I don't send info about the R session as this is not caused by the code (which works well when I use another input vector with no invalid geometries). So my question is more about whether there is an option to run the clipping command (or any other command) using RQGIS3 and set it to ignore the invalid geometries and still perform the clipping. (I could not find information about this in the package documentation). In QGIS this can be done by just adjusting the configurations.
Fixing the geometry of the vector is not an option. I have already tried this.
The text was updated successfully, but these errors were encountered: