Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#3931 closed defect (fixed)

NFW file causes NITF file to lose false northing

Reported by: jwderos Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.7.1
Severity: normal Keywords: nitf hdr nfw
Cc:

Description

I have an IKONOS NITF dataset with an image in Chile. The dataset includes an NFW file. When I run gdalinfo on the NITF in the context of the other IKONOS files, it loses the false northing value and puts the image in Canada's Baffin Bay. If I copy the NITF file elsewhere and run gdalinfo without the accompanying NFW file, the image has correct coordinates.

I think I have tracked down the bug to line 1463 of file "frmts/nitf/nitfdataset.cpp". To determine if the image is in the northern hemisphere, it adds up all of the latitudes and if the sum is less than zero, sets the isNorth flag to false. However, in the case of this scene, all of those values are positive due to a large false northing value. The code then moves the image into the northern hemisphere. I don't know how to extract the false northing value from the projection, so I just added a "0 &&" to the if statement so that NFW files will never be processed with NITF files.

Change History (7)

comment:1 Changed 7 years ago by Even Rouault

Could you paste/attach here the output of "gdalinfo your_nitf_file", the corresponding .nfw file and the corresponding .prj file ?

comment:2 Changed 7 years ago by Even Rouault

I meant .hdr file (instead of .prj)

comment:3 Changed 7 years ago by jwderos

Here is the gdal output:

Driver: NITF/National Imagery Transmission Format
Files: po_321538_blu_0000000.ntf
       po_321538_blu_0000000.nfw
Size is 2846, 2353
Coordinate System is:
PROJCS["UTM Zone 19, Southern Hemisphere",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9108"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-69],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
Origin = (499187.630000000004657,7796873.969999999739230)
Pixel Size = (4.000000000000000,-4.000000000000000)
Metadata:
  NITF_FHDR=NITF02.00
  NITF_CLEVEL=04
  NITF_STYPE=
  NITF_OSTAID=Thornton
  NITF_FDT=20164048ZMAR09
  NITF_FTITLE=po_321538_blu_0000000.ntf                                  M  GC   UCT
  NITF_FSCLAS=U
  NITF_FSCODE=
  NITF_FSCTLH=
  NITF_FSREL=
  NITF_FSCAUT=
  NITF_USE00A_ANGLE_TO_NORTH=270
  NITF_USE00A_MEAN_GSD=000.0
  NITF_USE00A_DYNAMIC_RANGE=
  NITF_USE00A_OBL_ANG=06.76
  NITF_STDIDC_ACQUISITION_DATE=20000706143228
  NITF_STDIDC_MISSION=IKONOS_01
  NITF_STDIDC_PASS=01
  NITF_STDIDC_OP_NUM=165
  NITF_STDIDC_START_SEGMENT=AA
  NITF_STDIDC_REPRO_NUM=00
  NITF_STDIDC_REPLAY_REGEN=000
  NITF_STDIDC_START_COLUMN=001
  NITF_STDIDC_START_ROW=00001
  NITF_STDIDC_END_SEGMENT=AA
  NITF_STDIDC_END_COLUMN=003
  NITF_STDIDC_END_ROW=00003
  NITF_STDIDC_COUNTRY=CI
  NITF_STDIDC_WAC=1194
  NITF_STDIDC_LOCATION=1955S06857W
  NITF_USE00A_ROLL_ANG=
  NITF_USE00A_N_REF=00
  NITF_USE00A_REV_NUM=00001
  NITF_USE00A_N_SEG=001
  NITF_USE00A_MAX_LP_SEG=
  NITF_USE00A_SUN_EL=+37.5
  NITF_USE00A_SUN_AZ=038.2
  NITF_FSCTLN=
  NITF_FSDWNG=
  NITF_FSCOP=00000
  NITF_FSCPYS=00000
  NITF_ENCRYP=0
  NITF_ONAME=
  NITF_OPHONE=1.703.480.7539
  NITF_IID1=0000023165
  NITF_IDATIM=06143228ZJUL00
  NITF_TGTID=
  NITF_ITITLE=06JUL00IK0101165po_321538_blu_0000000
  NITF_ISCLAS=U
  NITF_ISCODE=
  NITF_ISCTLH=
  NITF_ISREL=
  NITF_ISCAUT=
  NITF_ISCTLN=
  NITF_ISDWNG=
  NITF_ISORCE=IKONOS
  NITF_PVTYPE=INT
  NITF_IREP=MONO
  NITF_ICAT=MS
  NITF_ABPP=11
  NITF_PJUST=R
  NITF_IMAGE_COMMENTS=License is Nextview                                                             
  NITF_IC=NC
  NITF_IMODE=B
  NITF_IDLVL=1
  NITF_IALVL=0
  NITF_ILOC_ROW=0
  NITF_ILOC_COLUMN=0
  NITF_CCS_ROW=0
  NITF_CCS_COLUMN=0
  NITF_IMAG=1.0 
RPC Metadata:
  LINE_OFF=1176
  LINE_SCALE=1177
  SAMP_OFF=1423
  SAMP_SCALE=1423
  LONG_OFF=-68.9533
  LONG_SCALE=0.0545
  LAT_OFF=-19.967
  LAT_SCALE=0.0426
  HEIGHT_OFF=4373
  HEIGHT_SCALE=834
  LINE_NUM_COEFF=-388644.8 336609.7 -999999900 -8234936 -148431.8 9369.537 2446983 196495.6 -7716752 21579.92 2465.075 36.31567 -8394.775 192.5813 -16627.62 -13043.07 -1453.757 -6488.269 9009.866 -16.6849 
  LINE_DEN_COEFF=998703100 150235.4 7709159 -2157480 8386.099 -2643.633 -6351.837 17778.1 13045.59 610.782 -7.999414 0.9765391 -1.185979 4.015064 -3.007903 -0.8248507 -3.858656 -31.332 -20.48704 0.6513371 
  SAMP_NUM_COEFF=774928 999999900 235954.1 -16036020 7987744 -809690.6 -439592.3 150745.9 1549.719 12456.69 3839.194 17919.59 14862.94 -645.0552 8445.614 1.167605 334.455 -1792.213 -2695.655 12.45276 
  SAMP_DEN_COEFF=998215100 150162 7705392 -2156426 8382.001 -2642.342 -6348.733 17769.41 13039.22 610.4836 -7.995506 0.976062 -1.185399 4.013102 -3.006434 -0.8244475999999999 -3.856771 -31.31669 -20.47703 0.6510188 
  MIN_LONG=-68.98054999999999
  MAX_LONG=-68.92605
  MIN_LAT=-19.9883
  MAX_LAT=-19.9457
Corner Coordinates:
Upper Left  (  499187.630, 7796873.970) ( 69d 1'17.65"W, 70d16'40.75"N)
Lower Left  (  499187.630, 7787461.970) ( 69d 1'17.33"W, 70d11'36.92"N)
Upper Right (  510571.630, 7796873.970) ( 68d43'9.51"W, 70d16'39.97"N)
Lower Right (  510571.630, 7787461.970) ( 68d43'13.64"W, 70d11'36.14"N)
Center      (  504879.630, 7792167.970) ( 68d52'14.53"W, 70d14'8.67"N)
Band 1 Block=1024x1024 Type=UInt16, ColorInterp=Undefined

Here is the nfw file:

4.0000000000
0
0
-4.0000000000
499189.63
7796871.97

Here is the hdr file:

Producer: GeoEye
Project Name: 0071042193-00005 / CI / Image Date 07/06/2000
Filename: po_321538_blu_0000000.ntf
Band: Blue
Bits/Pixel: 11
Number of Bands: 1
Datum: WGS84
Selected Projection: Universal Transverse Mercator
Zone: 19
UL Map X (Easting): 499189.63 meters
UL Map Y (Northing): 7796871.97 meters
Pixel Size X: 4.0000000000 meters
Pixel Size Y: 4.0000000000 meters
Product Order Map Units:  meters
Columns: 2846 pixels
Rows: 2353 pixels

comment:4 Changed 7 years ago by Even Rouault

I can't understand how you can get both PROJCS["UTM Zone 19, Southern Hemisphere", and PARAMETER["false_northing",0]. What is the output of gdalinfo without any .nfw and .hdr file ? Also, if you are in position to build GDAL yourself, could you build the nitfdump utility (on Linux, cd frmts/nitf; make nitfdump ; on Windows nmake /f makefile.vc nitfdump.exe from frmts/nitf) and run nitfdump -tre on the nitf file ?

comment:5 Changed 7 years ago by jwderos

Here is the output without either the .nfw or .hdr file:

Driver: NITF/National Imagery Transmission Format
Files: po_321538_blu_0000000.ntf
Size is 2846, 2353
Coordinate System is:
PROJCS["UTM Zone 19, Southern Hemisphere",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9108"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-69],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",10000000],
    UNIT["Meter",1]]
Origin = (499185.999472759198397,7796875.000637754797935)
Pixel Size = (4.001054481546572,-4.001275510204219)
Metadata:
  NITF_FHDR=NITF02.00
  NITF_CLEVEL=04
  NITF_STYPE=
  NITF_OSTAID=Thornton
  NITF_FDT=20164048ZMAR09
  NITF_FTITLE=po_321538_blu_0000000.ntf                                  M  GC   UCT
  NITF_FSCLAS=U
  NITF_FSCODE=
  NITF_FSCTLH=
  NITF_FSREL=
  NITF_FSCAUT=
  NITF_USE00A_ANGLE_TO_NORTH=270
  NITF_USE00A_MEAN_GSD=000.0
  NITF_USE00A_DYNAMIC_RANGE=
  NITF_USE00A_OBL_ANG=06.76
  NITF_STDIDC_ACQUISITION_DATE=20000706143228
  NITF_STDIDC_MISSION=IKONOS_01
  NITF_STDIDC_PASS=01
  NITF_STDIDC_OP_NUM=165
  NITF_STDIDC_START_SEGMENT=AA
  NITF_STDIDC_REPRO_NUM=00
  NITF_STDIDC_REPLAY_REGEN=000
  NITF_STDIDC_START_COLUMN=001
  NITF_STDIDC_START_ROW=00001
  NITF_STDIDC_END_SEGMENT=AA
  NITF_STDIDC_END_COLUMN=003
  NITF_STDIDC_END_ROW=00003
  NITF_STDIDC_COUNTRY=CI
  NITF_STDIDC_WAC=1194
  NITF_STDIDC_LOCATION=1955S06857W
  NITF_USE00A_ROLL_ANG=
  NITF_USE00A_N_REF=00
  NITF_USE00A_REV_NUM=00001
  NITF_USE00A_N_SEG=001
  NITF_USE00A_MAX_LP_SEG=
  NITF_USE00A_SUN_EL=+37.5
  NITF_USE00A_SUN_AZ=038.2
  NITF_FSCTLN=
  NITF_FSDWNG=
  NITF_FSCOP=00000
  NITF_FSCPYS=00000
  NITF_ENCRYP=0
  NITF_ONAME=
  NITF_OPHONE=1.703.480.7539
  NITF_IID1=0000023165
  NITF_IDATIM=06143228ZJUL00
  NITF_TGTID=
  NITF_ITITLE=06JUL00IK0101165po_321538_blu_0000000
  NITF_ISCLAS=U
  NITF_ISCODE=
  NITF_ISCTLH=
  NITF_ISREL=
  NITF_ISCAUT=
  NITF_ISCTLN=
  NITF_ISDWNG=
  NITF_ISORCE=IKONOS
  NITF_PVTYPE=INT
  NITF_IREP=MONO
  NITF_ICAT=MS
  NITF_ABPP=11
  NITF_PJUST=R
  NITF_IMAGE_COMMENTS=License is Nextview                                                             
  NITF_IC=NC
  NITF_IMODE=B
  NITF_IDLVL=1
  NITF_IALVL=0
  NITF_ILOC_ROW=0
  NITF_ILOC_COLUMN=0
  NITF_CCS_ROW=0
  NITF_CCS_COLUMN=0
  NITF_IMAG=1.0 
RPC Metadata:
  LINE_OFF=1176
  LINE_SCALE=1177
  SAMP_OFF=1423
  SAMP_SCALE=1423
  LONG_OFF=-68.9533
  LONG_SCALE=0.0545
  LAT_OFF=-19.967
  LAT_SCALE=0.0426
  HEIGHT_OFF=4373
  HEIGHT_SCALE=834
  LINE_NUM_COEFF=-388644.8 336609.7 -999999900 -8234936 -148431.8 9369.537 2446983 196495.6 -7716752 21579.92 2465.075 36.31567 -8394.775 192.5813 -16627.62 -13043.07 -1453.757 -6488.269 9009.866 -16.6849 
  LINE_DEN_COEFF=998703100 150235.4 7709159 -2157480 8386.099 -2643.633 -6351.837 17778.1 13045.59 610.782 -7.999414 0.9765391 -1.185979 4.015064 -3.007903 -0.8248507 -3.858656 -31.332 -20.48704 0.6513371 
  SAMP_NUM_COEFF=774928 999999900 235954.1 -16036020 7987744 -809690.6 -439592.3 150745.9 1549.719 12456.69 3839.194 17919.59 14862.94 -645.0552 8445.614 1.167605 334.455 -1792.213 -2695.655 12.45276 
  SAMP_DEN_COEFF=998215100 150162 7705392 -2156426 8382.001 -2642.342 -6348.733 17769.41 13039.22 610.4836 -7.995506 0.976062 -1.185399 4.013102 -3.006434 -0.8244475999999999 -3.856771 -31.31669 -20.47703 0.6510188 
  MIN_LONG=-68.98054999999999
  MAX_LONG=-68.92605
  MIN_LAT=-19.9883
  MAX_LAT=-19.9457
Corner Coordinates:
Upper Left  (  499185.999, 7796875.001) ( 69d 0'28.00"W, 19d55'28.15"S)
Lower Left  (  499185.999, 7787459.999) ( 69d 0'28.02"W, 20d 0'34.44"S)
Upper Right (  510573.001, 7796875.001) ( 68d53'56.30"W, 19d55'28.05"S)
Lower Right (  510573.001, 7787459.999) ( 68d53'56.11"W, 20d 0'34.34"S)
Center      (  504879.500, 7792167.500) ( 68d57'12.11"W, 19d58'1.27"S)
Band 1 Block=1024x1024 Type=UInt16, ColorInterp=Undefined

As I mentioned in my initial report, it adds up the values of the latitudes, not including the false northing, and since they are all positive, overwrites the projection information with values for the Northern Hemisphere.

Here is the output from nitfdump:

Dump for po_321538_blu_0000000.ntf
File Metadata:
  NITF_FHDR=NITF02.00
  NITF_CLEVEL=04
  NITF_STYPE=
  NITF_OSTAID=Thornton
  NITF_FDT=20164048ZMAR09
  NITF_FTITLE=po_321538_blu_0000000.ntf                                  M  GC   UCT
  NITF_FSCLAS=U
  NITF_FSCODE=
  NITF_FSCTLH=
  NITF_FSREL=
  NITF_FSCAUT=
  NITF_FSCTLN=
  NITF_FSDWNG=
  NITF_FSCOP=00000
  NITF_FSCPYS=00000
  NITF_ENCRYP=0
  NITF_ONAME=
  NITF_OPHONE=1.703.480.7539
Segment 1 (Type=IM):
  HeaderStart=413, HeaderSize=2225, DataStart=2638, DataSize=18874368
  DLVL=1, ALVL=0, LOC=C0,R0, CCS=C0,R0

Segment 2 (Type=TX):
  HeaderStart=18877006, HeaderSize=282, DataStart=18877288, DataSize=2435
  DLVL=-1, ALVL=-1, LOC=C-1,R-1, CCS=C-1,R-1

Image Segment 0, 2846Px2353Lx1B x 16bits:
  PVTYPE=INT, IREP=MONO, ICAT=MS, IMODE=B, IC=NC, COMRAT=, ICORDS=U
  UL=(499185.999472759,7796875.00063775), UR=(510573.000527241,7796875.00063775)
  LL=(499185.999472759,7787459.99936224), LR=(510573.000527241,7787459.99936224)
  IDLVL=1, IALVL=0, ILOC R=0,C=0, IMAG=1.0 
  3 x 3 blocks of size 1024 x 1024
  Image TREs: PIAIMC(362) STDIDC(89) USE00A(107) RPC00B(1041)
  Comments:
License is Nextview                                                             
  Band 1: IREPBAND=, ISUBCAT=, 0 LUT entries.
  RPC00B:
    SUCCESS=1
    ERR_BIAS=4.14
    ERR_RAND=2
    LINE_OFF=1176
    SAMP_OFF=1423
    LAT_OFF =-19.967
    LONG_OFF=-68.9533
    HEIGHT_OFF=4373
    LINE_SCALE=1177
    SAMP_SCALE=1423
    LAT_SCALE =0.0426
    LONG_SCALE=0.0545
    HEIGHT_SCALE=834
    LINE_NUM_COEFF = -388644.8 336609.7 -999999900 -8234936 -148431.8 
                     9369.537 2446983 196495.6 -7716752 21579.92 
                     2465.075 36.31567 -8394.775 192.5813 -16627.62 
                     -13043.07 -1453.757 -6488.269 9009.866 -16.6849 
    LINE_DEN_COEFF = 998703100 150235.4 7709159 -2157480 8386.099 
                     -2643.633 -6351.837 17778.1 13045.59 610.782 
                     -7.999414 0.9765391 -1.185979 4.015064 -3.007903 
                     -0.8248507 -3.858656 -31.332 -20.48704 0.6513371 
    SAMP_NUM_COEFF = 774928 999999900 235954.1 -16036020 7987744 
                     -809690.6 -439592.3 150745.9 1549.719 12456.69 
                     3839.194 17919.59 14862.94 -645.0552 8445.614 
                     1.167605 334.455 -1792.213 -2695.655 12.45276 
    SAMP_DEN_COEFF = 998215100 150162 7705392 -2156426 8382.001 
                     -2642.342 -6348.733 17769.41 13039.22 610.4836 
                     -7.995506 0.976062 -1.185399 4.013102 -3.006434 
                     -0.8244476 -3.856771 -31.31669 -20.47703 0.6510188 
    RPC Transform (499185.999473,7796875.00064,0) -> (-1.22575e+06,1.783e+07)
    RPC Transform (510573.000527,7796875.00064,0) -> (-1.25227e+06,1.78114e+07)
    RPC Transform (499185.999473,7787459.99936,0) -> (-1.22716e+06,1.78291e+07)
    RPC Transform (510573.000527,7787459.99936,0) -> (-1.25371e+06,1.78104e+07)
    RPC Transform (504879.5,7792167.5,0) -> (-1.23973e+06,1.78202e+07)
    RPC Transform (504879.5,7792167.5,300) -> (-1.23973e+06,1.78202e+07)
  USE00A TRE:
    NITF_USE00A_ANGLE_TO_NORTH=270
    NITF_USE00A_MEAN_GSD=000.0
    NITF_USE00A_DYNAMIC_RANGE=
    NITF_USE00A_OBL_ANG=06.76
    NITF_USE00A_ROLL_ANG=
    NITF_USE00A_N_REF=00
    NITF_USE00A_REV_NUM=00001
    NITF_USE00A_N_SEG=001
    NITF_USE00A_MAX_LP_SEG=
    NITF_USE00A_SUN_EL=+37.5
    NITF_USE00A_SUN_AZ=038.2
  STDIDC TRE:
    NITF_STDIDC_ACQUISITION_DATE=20000706143228
    NITF_STDIDC_MISSION=IKONOS_01
    NITF_STDIDC_PASS=01
    NITF_STDIDC_OP_NUM=165
    NITF_STDIDC_START_SEGMENT=AA
    NITF_STDIDC_REPRO_NUM=00
    NITF_STDIDC_REPLAY_REGEN=000
    NITF_STDIDC_START_COLUMN=001
    NITF_STDIDC_START_ROW=00001
    NITF_STDIDC_END_SEGMENT=AA
    NITF_STDIDC_END_COLUMN=003
    NITF_STDIDC_END_ROW=00003
    NITF_STDIDC_COUNTRY=CI
    NITF_STDIDC_WAC=1194
    NITF_STDIDC_LOCATION=1955S06857W
  Image Metadata:
    NITF_IID1=0000023165
    NITF_IDATIM=06143228ZJUL00
    NITF_TGTID=
    NITF_ITITLE=06JUL00IK0101165po_321538_blu_0000000
    NITF_ISCLAS=U
    NITF_ISCODE=
    NITF_ISCTLH=
    NITF_ISREL=
    NITF_ISCAUT=
    NITF_ISCTLN=
    NITF_ISDWNG=
    NITF_ISORCE=IKONOS
    NITF_PVTYPE=INT
    NITF_IREP=MONO
    NITF_ICAT=MS
    NITF_ABPP=11
    NITF_PJUST=R

comment:6 Changed 7 years ago by Even Rouault

Component: defaultGDAL_Raster
Keywords: nitf hdr nfw added
Milestone: 1.7.4
Resolution: fixed
Status: newclosed

ok, I now understand what happens. The issue was that the IGEOLO info was expressed in UTM MGRS (ICORDS = 'U') thus the dfLLY, etc.. are not latitudes but northings, always positive. The other point of confusion I had was because I was looking at the GDAL 1.8.0 codebase where I put a fix (r19313) some time ago to reset the name of the SRS (oSRSWork.Clear()) to avoid inconsistances between the SRS name and its attributes.

Should be fixed now in trunk (r21607), branches/1.8 (r21608) and branches/1.7 (r21609)

comment:7 Changed 4 years ago by Even Rouault

Milestone: 1.7.4

Milestone 1.7.4 deleted

Note: See TracTickets for help on using tickets.