Re: [gdal-dev] Using GDALRPCTransform with a pre-loaded DEM
> > --> this returns a GDALDatasetH. You need to GDALClose() it before > being able to reopen it, so that its content gets flushed to storage. > Well, I have to say I'm impressed. Everything works smoothly. Thank you for your help :) Julien Osman. ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Using GDALRPCTransform with a pre-loaded DEM
On jeudi 1 octobre 2020 17:17:41 CEST Julien Osman wrote: > Dear Frank, > > Thank you for this great advice. It seems to be the best options. > > Nevertheless, I fail to make it work. I use the SRTM DEM, witch consist > of a bunch of files in a directory. So I load each file in a Dataset, > then I build a VRT file that I store as a memory dataset. Then I provide > this dataset to my RPCTransformer. But it doesn't work, I get "ERROR 4: > No such file or directory". If I try to open the VRT file directly with > GDALOpen, I get the same error. I also tried to open the srtm files > using GDALOpenShared, for the same result. > > For example : > > std::vector vrtDatasetList(2); > vrtDatasetList[0] = GDALOpenShared("srtm1.hgt", GA_ReadOnly); > vrtDatasetList[1] = GDALOpenShared("srtm2.hgt", GA_ReadOnly); > GDALBuildVRT("/vsimem/inmemdem.vrt", 2, vrtDatasetList.data(), > nullptr, nullptr, nullptr); --> this returns a GDALDatasetH. You need to GDALClose() it before being able to reopen it, so that its content gets flushed to storage. > GDALDataset* poDS = reinterpret_cast *>(GDALOpen("/vsimem/inmemdem.vrt", GA_ReadOnly)); > > When I run this, poDS is nullptr. > > Could you guide me to the correct way to do it? > > Best regards. > Julien Osman. > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/gdal-dev -- Spatialys - Geospatial professional services http://www.spatialys.com ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Using GDALRPCTransform with a pre-loaded DEM
Dear Frank, Thank you for this great advice. It seems to be the best options. Nevertheless, I fail to make it work. I use the SRTM DEM, witch consist of a bunch of files in a directory. So I load each file in a Dataset, then I build a VRT file that I store as a memory dataset. Then I provide this dataset to my RPCTransformer. But it doesn't work, I get "ERROR 4: No such file or directory". If I try to open the VRT file directly with GDALOpen, I get the same error. I also tried to open the srtm files using GDALOpenShared, for the same result. For example : std::vector vrtDatasetList(2); vrtDatasetList[0] = GDALOpenShared("srtm1.hgt", GA_ReadOnly); vrtDatasetList[1] = GDALOpenShared("srtm2.hgt", GA_ReadOnly); GDALBuildVRT("/vsimem/inmemdem.vrt", 2, vrtDatasetList.data(), nullptr, nullptr, nullptr); GDALDataset* poDS = reinterpret_cast(GDALOpen("/vsimem/inmemdem.vrt", GA_ReadOnly)); When I run this, poDS is nullptr. Could you guide me to the correct way to do it? Best regards. Julien Osman. ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Using GDALRPCTransform with a pre-loaded DEM
Julien, The least disruptive approach to this would be for you to store your DEM in a "memory dataset" and reference that. I've done this in the past when I had it in a numpy array by using the numpy driver. The "MEM" dataset can be used to reference approximately arbitrary in-memory arrays. Best regards, Frank On Mon, Sep 28, 2020 at 8:21 AM Julien Osman wrote: > Dear GDAL community, > > I use the RPC transformer available in GDAL (GDALCreateRPCTransformer > and GDALRPCTransform). > > To provide a DEM to the transformer, one needs to set the option > "RPC_DEM" with the path to the DEM file. In my workflow, this is not > very convenient because the DEM is already loaded in memory as a > GDALDataset. This means that I need to write it to the disk and let > GDALCreateRPCTransformer load it again. In my opinion, it would make > sens to open a little the API so one can provide the DEM directly as a > GDALDataset. > > If this is OK for you, I can implement this functionality and propose a > Pull Request. The solution I see would be to add a function > GDALRPCAddDEM, similar to GDALRPCOpenDEM without the part opening the > GDALDataset. What do you think? > > Best regards. > Julien Osman. > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/gdal-dev -- ---+-- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | +1 650-701-7823 and watch the world go round - Rush| Geospatial Software Developer ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev