1

So I am using GDAL Clip raster by mask area. I tried clipping a temporary raster to mask area and started getting errors that an error had occurred creating the output file. It seems that the issue was that GDAL could not find the mask file which was located on an external drive, even though the mask file was located on the QGIS 3.14 legend.

    gdalwarp -of GTiff -cutline /Volumes/Windows&Mac/Mono_Watershed/HU8_18090101_Watershed.shp -cl HU8_18090101_Watershed....
    /bin/sh: Mac/Mono_Watershed/HU8_18090101_Watershed.shp: No such file or directory
         
         
         
    FAILURE: No target filename specified.

Copying the files to my macOS Catalina (10.15.17) desktop fixed the issue. But it still irks me that GDAL failed to see the files on the external drive. Any ideas why this would be the case?

Maybe similar to this topic, but the call to the file and error seem a bit different and in this case it appears that it has something to do with the file location (external drive vs desktop).

2
  • 1
    Doesn't it rather look like the & character truncates the path?
    – user30184
    Mar 28, 2022 at 21:17
  • Probably right. Didn't name that volume well.... Mar 28, 2022 at 21:28

1 Answer 1

3

The & ampersand is a shell control character.

Wrap your path that contains the & in single quotes or escape the & with a backslash:

'/Volumes/Windows&Mac/Mono_Watershed/HU8_18090101_Watershed.shp'
/Volumes/Windows\&Mac/Mono_Watershed/HU8_18090101_Watershed.shp

e.g.

gdalwarp -of GTiff -cutline '/Volumes/Windows&Mac/Mono_Watershed/HU8_18090101_Watershed.shp' -cl HU8_18090101_Watershed....
1
  • Looking at the second line it is pretty obvious that was happening now. Thanks! Mar 28, 2022 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.