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

GDAL-based algorithms should pass not only file path but also layer name #30292

Closed
northrivergeo opened this issue Jun 20, 2019 · 7 comments · Fixed by #30715
Closed

GDAL-based algorithms should pass not only file path but also layer name #30292

northrivergeo opened this issue Jun 20, 2019 · 7 comments · Fixed by #30715
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

@northrivergeo
Copy link

I'm testing QGIS Master 64015a8 on Ubuntu 19.04

  1. Add a Image to QGIS

  2. Add a Polygon Layer from a Geopackage to QGIS covering a portion of the Raster.

  3. Run the Clip Raster By Mask Layer Processing Tool

  4. Process Fails with:
    GDAL command:
    gdalwarp -s_srs EPSG:2234 -t_srs EPSG:2234 -of GTiff -cutline /media/data/projects/planetzero/data/production.gpkg -crop_to_cutline /media/data/projects/planetzero/data/imagery/mosaic_2234.tif /home/rjhale/temp/randy.tif
    GDAL command output:
    ERROR 1: Cutline not of polygon type

  5. Replace the Polygon from a Geopackage with a Shapefile and it runs correctly.

Screenshot from 2019-06-20 10-03-10

I've checked the polygon layer and set "do not filter" for invalid features just in case. That didn't help or hurt.

I wasn't sure about attaching files since image + geopackage will be about 25MB. I can though if I need to.

@northrivergeo northrivergeo added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jun 20, 2019
@gioman
Copy link
Contributor

gioman commented Jun 20, 2019

@rjhale1971 is the geopackage a MULTIpolygon? is yes that is not accepted by gdalwarp, not a QGIS issue (I think that is the source of the error message).

@gioman gioman added Feedback Waiting on the submitter for answers Processing Relating to QGIS Processing framework or individual Processing algorithms labels Jun 20, 2019
@northrivergeo northrivergeo changed the title Clip Raster By Mask Layer in 2.7 Clip Raster By Mask Layer in 3.7 Master Jun 20, 2019
@northrivergeo
Copy link
Author

You are correct - It is a Multipolygon! I didn't know those weren't acceptable....and actually I hadn't looked at the polygon type. This can be closed then.

@northrivergeo
Copy link
Author

northrivergeo commented Jun 20, 2019

Actually.........I'm still getting an error. I went back and double checked with a polygon (non-multi) and I still get the same error. Let me paste the new error message:

GDAL command:
gdalwarp -s_srs EPSG:2234 -t_srs EPSG:2234 -of GTiff -cutline /media/data/projects/planetzero/data/production.gpkg -crop_to_cutline /media/data/projects/planetzero/data/imagery/mosaic_2234.tif /home/rjhale/temp/deleteme.tif
GDAL command output:
ERROR 1: Cutline not of polygon type.

No where in the error message is my cut layer mentioned. It appears to be getting left out. Let me test this by copying an d pasting that command outside of QGIS.

@gioman
Copy link
Contributor

gioman commented Jun 20, 2019

production.gpkg

can you attach it? @rjhale1971

@northrivergeo
Copy link
Author

I have attached the geopackage with a multipolygon, polygon, and a raster.

After trying it one more time tonight it seems to be working. So I think I will stop for now. Sorry for the wrong report. I must have been doing something wrong.

production.zip

@gioman
Copy link
Contributor

gioman commented Jun 21, 2019

@rjhale1971 there is definitely a bug.

With the attached datasurce, a multi layer datasource, the GDAL command that is created by Processing is like:

gdalwarp -of GTiff -cutline production.gpkg -crop_to_cutline production.gpkg OUTPUT.tif

but has there are >1 vector layers in the source it should be

gdalwarp -of GTiff -cutline production.gpkg -cl park -crop_to_cutline production.gpkg OUTPUT.tif

where "park" is one of the vector layers in the datasoource.

The second "production.gpkg" represent the input raster layer, and in this case is ok because there is only 1 inside the GPKG, but there could be more, in this case I'm not sure what the parameter to be used on the command line... it must be checked too if Processing does the right thing or not also in this case.

@gioman gioman changed the title Clip Raster By Mask Layer in 3.7 Master Missing parameter in "Clip Raster By Mask Layer" Jun 21, 2019
@gioman gioman removed the Feedback Waiting on the submitter for answers label Jun 21, 2019
@northrivergeo
Copy link
Author

Ahhh. OK. I personally broke a bug reporting rule by changing my process and I couldn't recreate it - which is why I kept backing off thinking I had a false bug.
It does seem to work completely fine if everything is a shapefile....which confirms what you said above.
Thanks for sticking with me on this. I was ready to give up.

@alexbruy alexbruy changed the title Missing parameter in "Clip Raster By Mask Layer" GDAL-based algorithms should pass not only file path but also layer name Jun 26, 2019
alexbruy added a commit that referenced this issue Jul 18, 2019
[processing] pass layer name to the gdalwarp to avoid issues with multi-layer datasources (fix #30292)
nyalldawson pushed a commit that referenced this issue Jul 18, 2019
multi-layer datasources (fix #30292)

(cherry picked from commit 109d1fb)
nyalldawson pushed a commit that referenced this issue Jul 18, 2019
multi-layer datasources (fix #30292)

(cherry picked from commit 109d1fb)
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