Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#5820 closed defect (fixed)

gdal_edit.py: fix -unsetstats with other metadata items

Reported by: Mike Taves Owned by: warmerdam
Priority: normal Milestone: 2.0.0
Component: Utilities Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

If there is another metadata item for a raster band, an error NameError: global name 'mt_out' is not defined is raised, otherwise statistics are only deleted if all keys start with "STATISTICS_".

The attached patch only deletes metadata items that start with "STATISTICS_", and preserves other items.

Attachments (1)

unsetstats.diff (2.4 KB ) - added by Mike Taves 8 years ago.
git diff --no-prefix > unsetstats.diff

Download all attachments as: .zip

Change History (5)

by Mike Taves, 8 years ago

Attachment: unsetstats.diff added

git diff --no-prefix > unsetstats.diff

comment:1 by Even Rouault, 8 years ago

The change seems larger than needed. It is just a typo. You could probably replace mt_out by md_out and it should work, no ? That said your version is OK too...

comment:2 by Mike Taves, 8 years ago

Yes, correcting the typo fixes the core issue too. The other changes deletes only the statistics tags and preserving others in place, rather than rewriting all metadata tags using a Python dict. It's your call on what is most appropriate.

comment:3 by Even Rouault, 8 years ago

Resolution: fixed
Status: newclosed

Drivers are supposed to behave the same whereas you replace all metadata or nullify items, although I suspect some might have problems clearing existing metadata with one or the other way, but that would be driver bugs. The GTiff one is fine for that at least.

trunk r28344 "gdal_edit.py: fix -unsetstats when band metadata has items that don't begin with STATISTICS_ (patch by mwtoews, #5820)"

comment:4 by Even Rouault, 7 years ago

Milestone: 2.02.0.0

Milestone renamed

Note: See TracTickets for help on using tickets.