Opened 18 years ago

Closed 16 years ago

#1147 closed defect (fixed)

[PATCH] Writing NITF files using UTM Mode and Southern Zones

Reported by: dany.houde@… Owned by: Even Rouault
Priority: normal Milestone: 1.5.0
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: nitf utm
Cc: warmerdam

Description (last modified by warmerdam)

When writing NITF files using GDAL's UTM mode, if the input data is 
georeferenced in a Southern zone, the written file seems to have invalid 
vertical spacing and extents information. More accurately, both the vertical 
spacing and the vertical extents of the new image seem to be ten times smaller 
than those of the input file. The horizontal information appears not to be 
affected in this way.

Attachments (1)

gdal_svn_trunk_utm_nitf_bug1147.patch (1.9 KB ) - added by Even Rouault 17 years ago.
Patch to check that UTM northings and eastings are within NITF valid range

Download all attachments as: .zip

Change History (6)

comment:1 by Even Rouault, 17 years ago

I've been able to reproduce it. I've forged a geotiff whose BBOX is ulx=0° uly=-40° lrx=1° lry=-41° (EPSG:4326) via :

gdal_translate -a_ullr 0 -40 1 -41 anything.tif southern.tif

Then I warped into EPSG:32730 (UTM 30 South) :

gdalwarp -co "ICORDS=S" -of NITF -t_srs EPSG:32730 \
 southern.tif southern_utm_s.nitf

gdalinfo gives :

Origin = (752320.797047970467247,5567931.203170028515160)
Pixel Size = (328.405904059040665,-328.406340057637806)

Everything is right.

But... if I use EPSG:32630 (UTM 30 North) instead, I get:

Origin = (752320.797047970467247,-443206.579250720445998)
Pixel Size = (328.405904059040665,-32.841498559077898)

This is obviously wrong (indeed, my first try was to chose 32630 before realizing that it was 32730 for southern hemispere...)

Now, let's dig into the code and the spec. We notice that for the IGEOLO record in UTM coordinates we have 2 characters for the UTM zone, 6 for the easting and 7 for the northing. Obviously southern latitudes in northern UTM projection need an extra character for the minus sign. Hence the bug.

There's nothing we can do, expect check that we try to write 8 characters and that there's only room for 7 and in that case warn the user. This should also be done for eastings : if you have a source file which is going "outside" of its UTM band, you may have negative eastings or big positive eastings like -123,456 or 1,234,567 which overflow the 6 characters for eastings.

I also think that there's probably a flow in the NITF specification because I don't see how you can handle a UTM image located in the neighbourhood of the equator and whose upper part is in the northern hemisphere and the lower part in the sounthern. If you choose EPSG:326XX, the southern part will need negative values (as long as your above -1,000,000 / around 9° south, it's OK). If you choose EPSG:327XX, 0° latitude is 10,000,000, so you can't choose it at all.

comment:2 by Even Rouault, 17 years ago

The attached patch implements the checks I mention in my previous post.

by Even Rouault, 17 years ago

Patch to check that UTM northings and eastings are within NITF valid range

comment:3 by Even Rouault, 17 years ago

Milestone: 1.5.0
Priority: highnormal
Summary: Writing NITF files using UTM Mode and Southern Zones[PATCH] Writing NITF files using UTM Mode and Southern Zones

comment:4 by warmerdam, 16 years ago

Cc: warmerdam added
Description: modified (diff)
Owner: changed from warmerdam to Even Rouault

Even,

Please go ahead and apply your patch. I don't forsee having time to do a good review myself.

comment:5 by Even Rouault, 16 years ago

Keywords: nitf utm added
Resolution: fixed
Status: newclosed

Commited in r13212

Note: See TracTickets for help on using tickets.