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

Check if the the FIELDS_MAPPING type can be passed to qgis_process #40

Closed
cmber opened this issue Mar 3, 2021 · 4 comments
Closed

Check if the the FIELDS_MAPPING type can be passed to qgis_process #40

cmber opened this issue Mar 3, 2021 · 4 comments

Comments

@cmber
Copy link

cmber commented Mar 3, 2021

I'm trying to use the refactor fields algorithm in R (Win 10) but can't make it work. The code I'm using is:

test<- qgis_run_algorithm(
"native:refactorfields",
INPUT = shape,
FIELDS_MAPPING = "[{'expression': '"id"','length': 10,'name': 'id','precision': 0,'type': 4},{'expression': '"nom"','length': 80,'name': 'nom','precision': 0,'type': 10},{'expression': '"clon"','length': 80,'name': 'clon','precision': 0,'type': 10},{'expression': '"use"','length': 80,'name': 'use','precision': 0,'type': 10},{'expression': '"date"','length': 10,'name': 'date','precision': 0,'type': 14},{'expression': '"area"','length': 10,'name': 'area','precision': 1,'type': 6}]",
#OUTPUT = TRUE,
.quiet = TRUE
)

The FIELDS_MAPPING argument was copied directly from QGIS. The error I get is:

Error in processx::run(path, ...) :
System command 'qgis_process-qgis-ltr.bat' failed, exit status: 1, stderr:
E> ERROR: An error was encountered while checking parameter values
E> Incorrect parameter value for FIELDS_MAPPING

Any feedback will be appreciated.

Best
CM

@paleolimbot
Copy link
Collaborator

Are you sure that your quotes are lined up correctly for your FIELDS_MAPPING value? They look a bit off from here but that could be a copy/paste error.

That said I have a feeling this won't work until we implement the JSON interface for the command-line runner, since the FIELDS_MAPPING value isn't a simple string->object conversion.

@cmber
Copy link
Author

cmber commented Mar 3, 2021

I copied the field mapping argument from a python file where it runs just fine. So, I guess it could be the second reason you gave. Thanks

@paleolimbot
Copy link
Collaborator

Yes, but in R you probably have a problem because you have nested single and double quotes (so you might have to escape all the double quotes). (But it probably is the second reason I gave...)

@paleolimbot paleolimbot changed the title "native:refactorfields" error Check if the the FIELDS_MAPPING type can be passed to qgis_process Apr 17, 2021
@paleolimbot
Copy link
Collaborator

Closing this to keep track of in #56!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants