GDAL/PROJ fails to get SRS for gdalwarp

315 Views Asked by At

I'm having an ongoing issue with latest versions of GDAL (3.5.2, 3.6.0). I have an application that depends on the GDAL library for a number of functions, in this case merging multiple rasters and outputting a GeoTIFF. Previously, I was using gdal 2.4.0 for the longest time, but recently have been trying to upgrade the dependency to gdal 3.

The application crashes when I attempt to export a GeoTIFF. Through intensive debugging, I've narrowed down the error to this call stack:

  • gdald.dll!OGRSpatialReference::importFromEPSGA(int nCode) Line 11466 C++
  • gdald.dll!OGRSpatialReference::importFromEPSG(int nCode) Line 11615 C++
  • gdald.dll!OGRSpatialReference::SetFromUserInput(const char * pszDefinition, const char * const * papszOptions) Line 3758 C++
  • gdald.dll!OGRSpatialReference::SetFromUserInput(const char * pszDefinition) Line 3658 C++
  • gdald.dll!OSRSetFromUserInput(void * hSRS, const char * pszDef) Line 4045 C++
  • gdald.dll!IsValidSRS(const char * pszUserInput) Line 4460 C++
  • gdald.dll!GDALWarpAppOptionsNew(char * * papszArgv, GDALWarpAppOptionsForBinary * psOptionsForBinary) Line 4778 C++
  • app.exe!ExportGeotiffWorker::mergeAndExport(QVector rasterFiles) Line 133 C++

As far as I can tell, all the parameters of my function calls are valid. This is a simple retrieval of EPSG:4326. But when it gets down to this:

    auto obj = proj_create_from_database(d->getPROJContext(),
                                             "EPSG",
                                             osCode.c_str(),
                                             PJ_CATEGORY_CRS,
                                             true,
                                             nullptr);

proj_create_from_database returns null and everything crashes. I don't know if there is something wrong with my GDAL or something wrong with my PROJ or something wrong with my data files.

Some fine print: I'm using a build of gdal 3.6.0 from vcpkg, built with proj 9.1.0. But I've had the same problem with building gdal myself from GitHub with CMake, and with gdal built by conda-forge. So I don't know what could possibly be wrong.

0

There are 0 best solutions below