Feature request #4236
Updated by Alister Hood over 6 years ago
*PROBLEM AND SUGGESTED SOLUTION*
- .prj or .qpj files are not supported for raster formats
- Some raster formats (e.g. jpeg, bitmap) cannot include coordinate or projection information. These formats are typically used with world files to provide the coordinate information, in which case QGIS prompts for the CRS when the layer is added.
- as well as a world file, some raster files georeferenced by ArcGIS include projection information in a PAM (.aux.xml) file. QGIS supports this information (QGIS does not prompt for CRS if it is present).
In the case where:
1. a raster file did not come with projection information, or
2. a raster came with incorrect projection information, which the user has overriden in QGIS by setting another CRS,
it It would be good if QGIS could write the CRS to the file itself (if supported, e.g. for geotif), or to a create .aux.xml file.
Possibly the best solution would be for QGIS to write the files containing CRS information whenever the CRS is set for the layer in QGIS (so immediately information, probably after the layer is loaded in the first case). If this happened automatically it would be undesirable (as per comment 8 below), especially so if the "CRS prompting for new layers" option is not set to "Prompt for CRS". But it would probably be fine if the user was prompted e.g. "Do you want to write this CRS to file?", or if there was a button in the "Set layer CRS" dialog to "write selected CRS to file". Personally I think a button in the "Set layer CRS" dialog would be best.
I also think it would be worth somehow indicating in the layers panel that layers have had their CRS set in QGIS but not written to file, although I am aware of the issues around "gui clutter" in the layers panel.
*ASSOCIATED PROBLEMS WHICH COULD BE AVOIDED*
I suspect there are quite a lot of features and tools which don't work correctly using layers which do not come with the correct projection information. At least some of these don't produce a helpful error message.
e.g. there are a number of places on the internet where people have encountered the following error when trying to clip a raster which comes with a world file but no projection information, using the gdaltools "clip raster by mask layer" option to "Crop the extent of the target dataset to take the nodata value from input":
<pre>
GDAL command output:
ERROR 1: Cannot compute bounding box of cutline
</pre>
In some cases people have figured out that they can work around the problem by saving to a new geotif first. In other cases they have given up on the "clip raster by mask layer" tool and looked for alternatives or changed their workflow. Often a number of other people have wasted their time trying to work out what layer is going out.
added.
N.B. I realise the error message comes from upstream, but guess maybe this kind of problem where a simple task fails without a clear error message leaves the impression that QGIS is unreliable i.e. try something and it might fail randomly, but if you are lucky it will work!
The suggested feature could prevent a lot of these problems and avoid the associated perception of QGIS being unreliable.
*KNOWN WORKAROUNDS*
See comment #7 for how functionality would require improvements to write the CRS information for a file using gdal_edit.py Gdal.
- .prj or .qpj files are not supported for raster formats
- Some raster formats (e.g. jpeg, bitmap) cannot include coordinate or projection information. These formats are typically used with world files to provide the coordinate information, in which case QGIS prompts for the CRS when the layer is added.
- as well as a world file, some raster files georeferenced by ArcGIS include projection information in a PAM (.aux.xml) file. QGIS supports this information (QGIS does not prompt for CRS if it is present).
In the case where:
1. a raster file did not come with projection information, or
2. a raster came with incorrect projection information, which the user has overriden in QGIS by setting another CRS,
it It would be good if QGIS could write the CRS to the file itself (if supported, e.g. for geotif), or to a create .aux.xml file.
Possibly the best solution would be for QGIS to write the files containing CRS information whenever the CRS is set for the layer in QGIS (so immediately information, probably after the layer is loaded in the first case). If this happened automatically it would be undesirable (as per comment 8 below), especially so if the "CRS prompting for new layers" option is not set to "Prompt for CRS". But it would probably be fine if the user was prompted e.g. "Do you want to write this CRS to file?", or if there was a button in the "Set layer CRS" dialog to "write selected CRS to file". Personally I think a button in the "Set layer CRS" dialog would be best.
I also think it would be worth somehow indicating in the layers panel that layers have had their CRS set in QGIS but not written to file, although I am aware of the issues around "gui clutter" in the layers panel.
*ASSOCIATED PROBLEMS WHICH COULD BE AVOIDED*
I suspect there are quite a lot of features and tools which don't work correctly using layers which do not come with the correct projection information. At least some of these don't produce a helpful error message.
e.g. there are a number of places on the internet where people have encountered the following error when trying to clip a raster which comes with a world file but no projection information, using the gdaltools "clip raster by mask layer" option to "Crop the extent of the target dataset to take the nodata value from input":
<pre>
GDAL command output:
ERROR 1: Cannot compute bounding box of cutline
</pre>
In some cases people have figured out that they can work around the problem by saving to a new geotif first. In other cases they have given up on the "clip raster by mask layer" tool and looked for alternatives or changed their workflow. Often a number of other people have wasted their time trying to work out what layer is going out.
added.
N.B. I realise the error message comes from upstream, but guess maybe this kind of problem where a simple task fails without a clear error message leaves the impression that QGIS is unreliable i.e. try something and it might fail randomly, but if you are lucky it will work!
The suggested feature could prevent a lot of these problems and avoid the associated perception of QGIS being unreliable.
*KNOWN WORKAROUNDS*
See comment #7 for how functionality would require improvements to write the CRS information for a file using gdal_edit.py Gdal.