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

v.clip: do not fail when clip map has no table connected #3416

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

landam
Copy link
Member

@landam landam commented Feb 11, 2024

In GRASS 8.4 v.clip fails when clip map has no table connected. Steps to reproduce in NC location:

v.extract input=boundary_county cat=1 output=aoi
v.db.connect aoi -d
v.clip input=geology clip=aoi output=geology_clip --o

v.clip currently fails with:

ERROR: Database connection for map <aoi> is not defined in DB file
Traceback (most recent call last):
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/scripts/v.dissolve", line 686, in <module>
    main()
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/scripts/v.dissolve", line 566, in main
    aggregate_columns_exist_or_fatal(input_vector, layer, columns_to_aggregate)
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/scripts/v.dissolve", line 265, in aggregate_columns_exist_or_fatal
    column_names = gs.vector_columns(vector, layer).keys()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/script/vector.py", line 128, in vector_columns
    s = read_command(
        ^^^^^^^^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 532, in read_command
    return handle_errors(returncode, stdout, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 344, in handle_errors
    raise CalledModuleError(module=module, code=code, returncode=returncode)
grass.exceptions.CalledModuleError: Module run `v.info --q -c map=aoi layer=1` ended with an error.
The subprocess ended with a non-zero return code: 1. See errors above the traceback or in the error output.
Traceback (most recent call last):
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/scripts/v.clip", line 226, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/scripts/v.clip", line 150, in main
    grass.run_command("v.dissolve", input=clip_map, output=temp_clip_map)
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 465, in run_command
    return handle_errors(returncode, result=None, args=args, kwargs=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 344, in handle_errors
    raise CalledModuleError(module=module, code=code, returncode=returncode)
grass.exceptions.CalledModuleError: Module run `v.dissolve input=aoi output=temp_20535` ended with an error.
The subprocess ended with a non-zero return code: 1. See errors above the traceback or in the error output.

It is regression, in GRASS 8.3 v.clip module works as expected.

@landam landam self-assigned this Feb 11, 2024
@landam landam added this to the 8.4.0 milestone Feb 11, 2024
@github-actions github-actions bot added vector Related to vector data processing Python Related code is in Python module labels Feb 11, 2024
@landam landam added the bug Something isn't working label Feb 11, 2024
@landam
Copy link
Member Author

landam commented Feb 11, 2024

See related #2388

@neteler neteler changed the title v.clip fails when clip map has no table connected v.clip: do not fail when clip map has no table connected Feb 11, 2024
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That should work.

It does seems that the whole code should behave better for this case, like fail nicely when user provides the names, but the table is missing.

Clearly, neither v.dissolve nor v.clip cover the case without a table in their tests.

@landam landam merged commit 50a1f20 into OSGeo:main Feb 12, 2024
25 checks passed
@landam landam deleted the v_clip_no_table branch February 12, 2024 11:07
jadenabrams100 pushed a commit to ncsu-csc472-spring2024/grass-CI-playground that referenced this pull request Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module Python Related code is in Python vector Related to vector data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants