Opened 13 years ago

Closed 12 years ago

#3634 closed enhancement (fixed)

[PATCH] RPC_DEM functionality in GDALRPCTransform

Reported by: bishop Owned by: Even Rouault
Priority: normal Milestone: 1.10.0
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords: RPC DEM GDALCreateRPCTransformer GDAL Warp GDALRPCTransform

Description (last modified by bishop)

I have found that GDAL has no code for RPC_DEM key. So I add code for RPC_DEM, also I add RPC_HEIGHT_SCALE for cases if height is not in meters (but, for example, in foots). There is one thing that should be fixed in future - every time while transforming, the GDALRPCTransform opens and closes DEM file.

Attachments (2)

gdal_rpc_demfile.patch (10.8 KB ) - added by bishop 13 years ago.
add support for DEM files
gdal_rpc_deminterpolation.patch (10.4 KB ) - added by bishop 13 years ago.
dem interpolation patch

Download all attachments as: .zip

Change History (12)

by bishop, 13 years ago

Attachment: gdal_rpc_demfile.patch added

add support for DEM files

comment:1 by bishop, 13 years ago

Summary: [patch] RPC_DEM functionality in GDALRPCTransform[PATCH] RPC_DEM functionality in GDALRPCTransform

comment:2 by Even Rouault, 13 years ago

Milestone: 1.8.0
Owner: changed from warmerdam to Even Rouault

I've made a few changes and commited them in r19864 and r19866. Test added in r19865.

The changes are :

  • lazy opening of the DEM file the first time we need it and close it only when the transform is destroyed (address the point in your comment)
  • caching of the inverse geotransform et coordinate transform
  • replace OGR errors -> CPL errors
  • test that dX, dY is in the extent of the dataset
  • replace GDT_Int16 by GDT_Int32 as we use array of int and not array of short
  • several fixes in the bDstToSrc == FALSE case that wasn't probably much tested (padfX[i] used instead of padfY[i] at line 736, poCT->Transform() was wrongly tested against OGRERR_xxx instead of TRUE/FALSE)

Please test and report if it still works for you.

comment:3 by bishop, 13 years ago

Great work! I have tested it. The result is more accurate (in case of output image size) and the speed is march faster (about 5 times). The test data with RPC was taken from DigitalGlobe samples ( - QuickBird: Ortho Ready Standard Satellite Imagery And DEM file was taken from here

comment:4 by Even Rouault, 13 years ago

Resolution: fixed
Status: newclosed

comment:5 by bishop, 13 years ago

Resolution: fixed
Status: closedreopened

I added cubic interpolation of elevation and config option (GDAL_RPCDEMINTERPOLATION) to choose between BILINEAR and CUBIC

by bishop, 13 years ago

dem interpolation patch

comment:6 by bishop, 12 years ago

Description: modified (diff)
Resolution: fixed
Status: reopenedclosed

comment:7 by Even Rouault, 12 years ago

Resolution: fixed
Status: closedreopened

The patch causes autotest/gcore/ to crash on transformer_5.

  TEST: transformer_5 ... 
Program received signal SIGSEGV, Segmentation fault.
*__GI___strcasecmp (s1=0x0, s2=0x7ffff61cf68d "near") at strcasecmp.c:65
65	strcasecmp.c: Aucun fichier ou dossier de ce type.
	in strcasecmp.c
(gdb) bt
#0  *__GI___strcasecmp (s1=0x0, s2=0x7ffff61cf68d "near") at strcasecmp.c:65
#1  0x00007ffff5ba7a15 in GDALCreateRPCTransformer (psRPCInfo=0x7fffffffcba0, bReversed=0, dfPixErrThreshold=0.10000000000000001, papszOptions=0xbf15b0) at gdal_rpc.cpp:415
#2  0x00007ffff5bafadb in GDALCreateGenImgProjTransformer2 (hSrcDS=0x939030, hDstDS=0x0, papszOptions=0xbf15b0) at gdaltransformer.cpp:1166
#3  0x00007ffff679490b in new_GDALTransformerInfoShadow (args=<value optimized out>) at extensions/gdal_wrap.cpp:4830
#4  _wrap_new_Transformer (args=<value optimized out>) at extensions/gdal_wrap.cpp:19357

You should test that pszDEMInterpolation is not NULL before passing it to EQUAL. Well, more exactly, I assume that if it is NULL, you should use bilinear.

For consistency with other options, the patch would also likely need to be extended to update GDALSerializeRPCTransformer() and GDALDeserializeRPCTransformer() to serialize/deserialize the new option (this is triggered when using warped VRT). The deserializer should be robust to the absence of the new option (i.e. accept XML produced by earlier versions).

comment:8 by bishop, 12 years ago

Description: modified (diff)

comment:9 by bishop, 12 years ago

Description: modified (diff)

Fixed in r24099. If everything ok, the ticket may be closed.

comment:10 by Even Rouault, 12 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.