Geotiff坐标转换错误 [英] Error on geotiff coordinate transformation

查看:517
本文介绍了Geotiff坐标转换错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出现错误和崩溃在OpenSUSE中运行它的GeoTiff图像生成经度,而对我的同事来说,它在Ubuntu中运行良好.对于gdal-v3和gdal-v2版本,错误有所不同,但是在OGRCreateCoordinateTransformation对象创建中似乎存在问题:在两种情况下均返回NULL.查看以下详细信息:

Have error and crash in an application using GDAL for extracting latitude & longitude from GeoTiff image running it in openSUSE, while it works fine in Ubuntu for my colleagues. Errors are different for gdal-v3 and gdal-v2 versions, however seems problem is in OGRCreateCoordinateTransformation object creation: returns NULL in both cases. See details below:

QGeoCoordinate toGeoCoordinate(double* adGeotransform, OGRSpatialReference& srcRef, int x, int y)
{
    double worldX = adGeotransform[0] + x * adGeotransform[1] + y * adGeotransform[2];
    double worldY = adGeotransform[3] + x * adGeotransform[4] + y * adGeotransform[5];

    OGRSpatialReference dstRef;
    dstRef.importFromEPSG(4326);
    QScopedPointer<OGRCoordinateTransformation> coordinateTransform(
                OGRCreateCoordinateTransformation(&srcRef, &dstRef));
    coordinateTransform->Transform(1, &worldX, &worldY);
    return QGeoCoordinate(worldY,   // lat
                          worldX);  // lon
}

QGeoRectangle extractCoordinate(const QString& path) 
{
    GDALAllRegister();
    GDALDataset *poDataset = (GDALDataset *) GDALOpen( path.toStdString().c_str(), GA_ReadOnly );
    _height = GDALGetRasterYSize(poDataset);
    _width = GDALGetRasterXSize(poDataset);

    double adGeotransform[6];
    poDataset->GetGeoTransform(adGeotransform);
    OGRSpatialReference srcRef(poDataset->GetProjectionRef());
    QGeoCoordinate _topLeft = toGeoCoordinate(adGeotransform, srcRef, 0, 0);
    QGeoCoordinate _bottomRight = toGeoCoordinate(adGeotransform, srcRef, _width, _height);

    return QGeoRectangle(_topLeft, _bottomRight);
}


GDAL 3(openSUSE):

  • gdal-3.0.4
  • libgeotiff5-1.5.1
  • libproj19-7.0.0
  • libgeos-3.8.0

  • GDAL 3 (openSUSE):

    • gdal - 3.0.4
    • libgeotiff5 - 1.5.1
    • libproj19 - 7.0.0
    • libgeos - 3.8.0
    • 错误1:PROJ:proj_create_from_database:找不到proj.db 错误1:PROJ:proj_create:格式无法识别/名称未知 错误6:无法从PROJCRS["WGS 84 / UTM zone 10N",BASEGEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["UTM zone 10N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",-123,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing",north,ORDER[2],LENGTHUNIT["metre",1]],ID["EPSG",32610]]' to'

      ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db ERROR 1: PROJ: proj_create: unrecognized format / unknown name ERROR 6: Cannot find coordinate operations from PROJCRS["WGS 84 / UTM zone 10N",BASEGEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["UTM zone 10N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",-123,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing",north,ORDER[2],LENGTHUNIT["metre",1]],ID["EPSG",32610]]' to'


      GDAL 2(openSUSE):

      • gdal2-2.4.2
      • libgeotiff5-1.5.1
      • libproj19-7.0.0
      • libgeos-3.8.0

      • GDAL 2 (openSUSE):

        • gdal2 - 2.4.2
        • libgeotiff5 - 1.5.1
        • libproj19 - 7.0.0
        • libgeos - 3.8.0
        • 错误6:无法加载PROJ.4库(libproj.so.15),OGRCoordinateTransformation的创建失败.

          ERROR 6: Unable to load PROJ.4 library (libproj.so.15), creation of OGRCoordinateTransformation failed.


          Ubuntu 18.03 LTS(正常运行):

          • libgdal-2.2.3
          • libgeotiff-1.4.2
          • libproj12-4.9.3

          • Ubuntu 18.03 LTS (works fine):

            • libgdal - 2.2.3
            • libgeotiff - 1.4.2
            • libproj12 - 4.9.3
            • 因此,寻求可能的解决方案:

              So asking for possible solutions:

              1. 错误导致的原因可能是:
                • 错误的库版本;
                • openSUSE上的构建标志错误吗?
              1. What the errors cause could be:
                • wrong libraries versions;
                • wrong build flags on openSUSE?

              推荐答案

              问题在PROJ库版本中使用.对于GDAL v2,需要使用libproj v6.但是,需要在openSUSE Tumbleweed中针对libproj19(proj v7)构建的libgeotiff5libspatialite.所以需要

              Problem is in PROJ library version used. For GDAL v2 need to use libproj v6. However required libgeotiff5 and libspatialite built against libproj19 (proj v7) in openSUSE Tumbleweed. So need to

              1. 卸载以下所有最新版本:libspatialitegeotifflibproj19gdal.
              2. 例如从此存储库中安装libproj15 首页:rogeroberholtzer
              3. 重建libspatialite& geotiff中的geotiff库针对自己安装的libproj15:

              1. Uninstall all recent versions of: libspatialite, geotiff, libproj19, gdal.
              2. Install libproj15 for example from this repo home:rogeroberholtzer
              3. Rebuild libspatialite & geotiff libraries from src.rpm against this installed libproj15 ourselves:

              rpmbuild --rebuild --clean libspatialite-4.3.0a-15.19.src.rpm
              rpmbuild --rebuild --clean geotiff-1.5.1-31.13.src.rpm
              

              这些软件包可以从 science 存储库中获取例子.

              These packages could be taken from science repo for example.

              安装内置软件包:rpm -Uvh *

              科学 rpm >回购.

              所有作品!享受! :)

              And all works! Enjoy! :)

              这篇关于Geotiff坐标转换错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆