QGIS GDAL – GDAL Clip Raster by Mask Layer Not Seeing Files on External Drive

clipfile pathqgis-3qgis-processingraster

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).

Best Answer

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....
Related Question