2

I have an HH polarised SAR image as follows:

SAR_4326

This is how it looks in QGIS in the default EPSG:4326 projection.

Now I would like to reproject this raster to ESRI:102020 (South Pole Lambert Azimuthal Equal Area projection). I can do this fine on QGIS and it looks as follows:

SAR_102020

This is fine. However when I try to do the same via gdalwarp

gdalwarp -s_srs EPSG:4326 -t_srs "+proj=laea +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs" -of GTiff s1a-ew-grd-hh-20200317t225506-20200317t225606-031721-03a873-001.tiff reproj.tiff

The reprojected raster is much darker as shown below:

enter image description here

Now its clear this is due to the scaling of the pixel values in the reprojection (0 to 4454 -> 0 to 15561). Why is this happening? To be more precise why is it that reprojecting in QGIS does not change the scale of pixel values whereas using gdalwarp (to do the same operation) does.

Following is the output of: gdalinfo s1a-ew-grd-hh-20200317t225506-20200317t225606-031721-03a873-001.tiff

Driver: GTiff/GeoTIFF
Files: s1a-ew-grd-hh-20200317t225506-20200317t225606-031721-03a873-001.tiff
Size is 17114, 16217
Coordinate System is `'
GCP Projection = 
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["unnamed",6378137,298.2572235604902,
            AUTHORITY["EPSG","4326"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
GCP[  0]: Id=1, Info=
          (0,0) -> (-51.9954921915471,-63.8957637448199,-8.30739736557007e-06)
GCP[  1]: Id=2, Info=
          (856,0) -> (-51.6000130781883,-63.815715063168,-7.20564275979996e-06)
GCP[  2]: Id=3, Info=
          (1712,0) -> (-51.2067866490764,-63.7345909047409,-6.34975731372833e-06)
GCP[  3]: Id=4, Info=
          (2568,0) -> (-50.8158212163499,-63.6524011044357,-5.67175447940826e-06)
GCP[  4]: Id=5, Info=
          (3424,0) -> (-50.4271244774541,-63.5691556256142,-5.11948019266129e-06)
GCP[  5]: Id=6, Info=
          (4280,0) -> (-50.0407035573213,-63.4848642668803,-4.66778874397278e-06)
GCP[  6]: Id=7, Info=
          (5136,0) -> (-49.6565645825152,-63.3995370021001,-4.2840838432312e-06)
GCP[  7]: Id=8, Info=
          (5992,0) -> (-49.2747128896954,-63.3131837931561,-3.96557152271271e-06)
GCP[  8]: Id=9, Info=
          (6848,0) -> (-48.8951531243128,-63.2258145292834,-3.68990004062653e-06)
GCP[  9]: Id=10, Info=
          (7704,0) -> (-48.5178892986398,-63.137439000881,-3.44961881637573e-06)
GCP[ 10]: Id=11, Info=
          (8560,0) -> (-48.1429244814785,-63.0480671835066,-3.24379652738571e-06)
GCP[ 11]: Id=12, Info=
          (9416,0) -> (-47.7702611312136,-62.9577089448684,-3.06125730276108e-06)
GCP[ 12]: Id=13, Info=
          (10272,0) -> (-47.3999010780518,-62.8663740661883,-2.89641320705414e-06)
GCP[ 13]: Id=14, Info=
          (11128,0) -> (-47.0318453355864,-62.774072407619,-2.75112688541412e-06)
GCP[ 14]: Id=15, Info=
          (11984,0) -> (-46.6660943012677,-62.6808137472396,-2.62446701526642e-06)
GCP[ 15]: Id=16, Info=
          (12840,0) -> (-46.3026477202025,-62.5866078306573,-2.50525772571564e-06)
GCP[ 16]: Id=17, Info=
          (13696,0) -> (-45.9415047735077,-62.4914643201849,-2.3944303393364e-06)
GCP[ 17]: Id=18, Info=
          (14552,0) -> (-45.5826639164266,-62.3953929451095,-2.29757279157639e-06)
GCP[ 18]: Id=19, Info=
          (15408,0) -> (-45.2261230682344,-62.2984033501513,-2.20630317926407e-06)
GCP[ 19]: Id=20, Info=
          (16264,0) -> (-44.8718794886445,-62.2005051720615,-2.12900340557098e-06)
GCP[ 20]: Id=21, Info=
          (17113,0) -> (-44.5227987861975,-62.1025193496058,-2.04984098672867e-06)
GCP[ 21]: Id=22, Info=
          (0,811) -> (-52.1641268544205,-63.7279283255242,-8.2729384303093e-06)
GCP[ 22]: Id=23, Info=
          (856,811) -> (-51.7705596488955,-63.6482918290304,-7.17397779226303e-06)
GCP[ 23]: Id=24, Info=
          (1712,811) -> (-51.37920636884,-63.5675853730759,-6.32274895906448e-06)
GCP[ 24]: Id=25, Info=
          (2568,811) -> (-50.9900754118974,-63.4858186348724,-5.64660876989365e-06)
GCP[ 25]: Id=26, Info=
          (3424,811) -> (-50.6031746536178,-63.4030013513872,-5.09805977344513e-06)
GCP[ 26]: Id=27, Info=
          (4280,811) -> (-50.2185112216204,-63.3191432787758,-4.64357435703278e-06)
GCP[ 27]: Id=28, Info=
          (5136,811) -> (-49.8360913880597,-63.2342542320574,-4.26638871431351e-06)
GCP[ 28]: Id=29, Info=
          (5992,811) -> (-49.4559207819494,-63.1483438993856,-3.94508242607117e-06)
GCP[ 29]: Id=30, Info=
          (6848,811) -> (-49.0780042190134,-63.0614220281417,-3.67313623428345e-06)
GCP[ 30]: Id=31, Info=
          (7704,811) -> (-48.7023458049096,-62.9734983497484,-3.43751162290573e-06)
GCP[ 31]: Id=32, Info=
          (8560,811) -> (-48.328948804408,-62.8845827047516,-3.22703272104263e-06)
GCP[ 32]: Id=33, Info=
          (9416,811) -> (-47.957816112128,-62.7946846312314,-3.04728746414185e-06)
GCP[ 33]: Id=34, Info=
          (10272,811) -> (-47.5889495486489,-62.7038139842191,-2.88244336843491e-06)
GCP[ 34]: Id=35, Info=
          (11128,811) -> (-47.2223505703829,-62.6119803199962,-2.73901969194412e-06)
GCP[ 35]: Id=36, Info=
          (11984,811) -> (-46.8580198546566,-62.5191932686744,-2.60677188634872e-06)
GCP[ 36]: Id=37, Info=
          (12840,811) -> (-46.4959572969994,-62.425462547937,-2.49128788709641e-06)
GCP[ 37]: Id=38, Info=
          (13696,811) -> (-46.136162451155,-62.3307976164,-2.38418579101562e-06)
GCP[ 38]: Id=39, Info=
          (14552,811) -> (-45.7786340773243,-62.2352080696662,-2.286396920681e-06)
GCP[ 39]: Id=40, Info=
          (15408,811) -> (-45.4233703525527,-62.1387034666748,-2.19140201807022e-06)
GCP[ 40]: Id=41, Info=
          (16264,811) -> (-45.0703690536836,-62.0412931603116,-2.11410224437714e-06)
GCP[ 41]: Id=42, Info=
          (17113,811) -> (-44.7224862047334,-61.9437940834308,-2.03680247068405e-06)
GCP[ 42]: Id=43, Info=
          (0,1622) -> (-52.3308693139328,-63.5599100150093,-8.23289155960083e-06)
GCP[ 43]: Id=44, Info=
          (856,1622) -> (-51.9391987359374,-63.4806804095238,-7.14045017957687e-06)
GCP[ 44]: Id=45, Info=
          (1712,1622) -> (-51.5497041627202,-63.4003863542306,-6.29294663667679e-06)
GCP[ 45]: Id=46, Info=
          (2568,1622) -> (-51.1623940759476,-63.3190373631339,-5.62053173780441e-06)
GCP[ 46]: Id=47, Info=
          (3424,1622) -> (-50.7772764394267,-63.2366430238614,-5.07477670907974e-06)
GCP[ 47]: Id=48, Info=
          (4280,1622) -> (-50.394358496716,-63.1532129356531,-4.62587922811508e-06)
GCP[ 48]: Id=49, Info=
          (5136,1622) -> (-50.0136466645894,-63.0687567494222,-4.2477622628212e-06)
GCP[ 49]: Id=50, Info=
          (5992,1622) -> (-49.6351467195353,-62.9832840036005,-3.9292499423027e-06)
GCP[ 50]: Id=51, Info=
          (6848,1622) -> (-49.2588636473071,-62.8968042931141,-3.65730375051498e-06)
..........
a whole lot of GCPs
..........
GCP[435]: Id=436, Info=
          (12840,16216) -> (-49.8147518977658,-59.3194238597005,-2.23796814680099e-06)
GCP[436]: Id=437, Info=
          (13696,16216) -> (-49.4795876491336,-59.2329471172809,-2.13459134101868e-06)
GCP[437]: Id=438, Info=
          (14552,16216) -> (-49.1461224280091,-59.1456118480941,-2.04611569643021e-06)
GCP[438]: Id=439, Info=
          (15408,16216) -> (-48.8143582979236,-59.057425332999,-1.96322798728943e-06)
GCP[439]: Id=440, Info=
          (16264,16216) -> (-48.4842969041853,-58.9683948252967,-1.88499689102173e-06)
GCP[440]: Id=441, Info=
          (17113,16216) -> (-48.158617675307,-58.8792657886883,-1.81421637535095e-06)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2020:03:18 05:05:15
  TIFFTAG_IMAGEDESCRIPTION=Sentinel-1A EW GRD HR L1
  TIFFTAG_SOFTWARE=Sentinel-1 IPF 003.20
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,16217.0)
Upper Right (17114.0,    0.0)
Lower Right (17114.0,16217.0)
Center      ( 8557.0, 8108.5)
Band 1 Block=17114x1 Type=UInt16, ColorInterp=Gray
7
  • Manually setting the max value does not change the appearance of the image? The higher the max value is, the darker the picture gets. – Babel Jan 28 at 12:51
  • You're right. I can set the max values manually via QGIS and that does fix the image. But I'm not sure why the scale changes during reprojection? How can I ensure that the pixel scale remains the same after reprojection via gdalwarp? – Ashwin Nair Jan 30 at 8:08
  • I once met a similar issue with aerial images which were much darker that they used to be from the original software. It was related to a bit-encoding; the hardware+software manufacturer of the acquisition device encoded the image in 12 bits, and I asked a classical GIS software, which at that time could only opened 8-bit imagery (and many 16-bit, but definitely not 12), to open it. It was obviously not rendered as I expected. Just a thought... – s.k Jan 30 at 8:28
  • Where are those high pixel values? Maybe there is a resampling bug. Or are the values all scaled to that new range? – bugmenot123 Jan 30 at 9:44
  • @bugmenot123 How can I find that out? – Ashwin Nair Jan 30 at 10:09
1

So the issue was with how QGIS was displaying the range of the raster. As stated in this answer, QGIS, by default does not calculate the range of the entire dataset but estimates it instead. This can be seen in Properties > Symbology > Band Rendering > Min/Max settings. The default option for accuracy is Estimate(faster). You need to set it to Actual(slower) to get the real max and min of the raster.

The true range of my original geotiff was 0 to 15561. The 0 to 4454 was just the estimate. So my reprojection was showing the true range while the orignal was showing the estimated range. I was able to confirm this via loading the raster and looking at the array & via the following commands

gdal_translate -stats src.tiff dummy.tiff
gdalinfo dummy.tiff

However it's weird to me that if Estimate is the default option for QGIS then the reprojection should have also automatically been scaled to 0 to 4454 just like the original geotiff.

1
  • 1
    I agree that it doesn't make sense to have Estimate as the default QGIS program setting. I've submitted a feature request to allow the default to be set to Actual. See github.com/qgis/QGIS/issues/41305 – Stu Smith Feb 1 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.