Open krirein opened 1 year ago
@krirein please attach a sample layer for which the issue does occur.
@agiudiceandrea
Attached is a zip-file containing the netcdf-file that is wrongly projected.
Thank you for your help!
@krirein please modify the issue report title mentioning the raster format.
NetCDF datasets are supported by QGIS thanks to the GDAL library.
The coordinates of the provided NetCDF dataset are recognized by the GDAL library in a different way from what you expect:
gdalinfo d04_hgt.nc -nomd --debug ON
[...]
GDAL_netCDF: driver detected file type=2, libnetcdf detected type=2
GDAL_netCDF: No UNIDATA NC_GLOBAL:Conventions attribute
GDAL_netCDF: var_count = 4
GDAL_netCDF: variable #1 [XLAT] was ignored
GDAL_netCDF: variable #2 [XLONG] was ignored
GDAL_netCDF: variable #3 [XTIME] was ignored
GDAL_netCDF: As 3 variables were ignored, creating subdataset list for reference. Variable #0 [HGT] is the main variable
GDAL_netCDF:
=====
SetProjectionFromVar( 65536, 0)
GDAL_netCDF: bIsGdalFile=0 bIsGdalCfFile=0 bSwitchedXY=0 bBottomUp=1
GDAL_netCDF: using variables XLONG and XLAT for GEOLOCATION
GDAL_netCDF: bGotGeogCS=0 bGotCfSRS=0 bGotCfGT=0 bGotCfWktSRS=0 bGotGdalSRS=0 bGotGdalGT=0
GDAL_netCDF: did not get geotransform from CF nor GDAL!
GDAL_netCDF: did not get projection from CF nor GDAL!
[...]
Driver: netCDF/Network Common Data Format
Files: d04_hgt.nc
Size is 108, 117
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 117.0)
Upper Right ( 108.0, 0.0)
Lower Right ( 108.0, 117.0)
Center ( 54.0, 58.5)
@krirein, it seems the provided NetCDF dataset is a WRF NetCDF dataset ("OUTPUT FROM WRF V3.9.1 MODEL") which does not "fully conform to the common netCDF conventions" https://www.ncl.ucar.edu/Applications/wrfnetcdf.shtml. See also: https://trac.osgeo.org/gdal/ticket/1637, https://lists.osgeo.org/pipermail/gdal-dev/2013-November/037579.html, https://lists.osgeo.org/pipermail/gdal-dev/2017-October/047410.html, http://geoexamples.blogspot.com/2013/09/reading-wrf-netcdf-files-with-gdal.html.
I suggest you to ask to the gdal-dev mailing list https://lists.osgeo.org/mailman/listinfo/gdal-dev or to open an issue report in the GDAL repository https://github.com/OSGeo/gdal and close this one.
@agiudiceandrea Thank you so much for your help! I have created a new issue report in the GDAL repository: https://github.com/OSGeo/gdal/issues/7199
Re-opening as this should be a QGIS improvement. Cf my comment in https://github.com/OSGeo/gdal/issues/7199#issuecomment-1421366420
Thanks @rouault for looking at this.
Hi QGIS developers, do you think this could be included in a future QGIS release? There is quite a bit of remote sensing data that is only reported with geolocation info in separate lat, lon arrays (and not with a projection), so fixing this issue would allow ingesting those data directly into QGIS.
What is the bug or the crash?
A raster file is wrongly projected in QGIS 3.22. After reading https://github.com/qgis/QGIS/issues/47158 I chose to set IGNORE_XY_AXIS_NAME_CHECKS=YES when adding the file, but this did not help.
The upper left corner of my layer has been assigned with coordinates (0,0), but should have been (69.628°N, 17.9877°E) Screenshot is added below:
Steps to reproduce the issue
From the top menu in QGIS choose: Layer - Add Layer - Add raster layer
Load a netcdf file and set IGNORE_XY_AXIS_NAME_CHECKS=YES
Press Add, select the variable(s) you would like to visualize and press Add layers.
Double-click on the added layer and in the Source-panel set the Assigned CRS to WGS 84 and press Apply.
The layer will now be wrongly projected.
Versions
3.22.16
Supported QGIS version
New profile
Additional context
No response