Opened 13 years ago

Closed 5 years ago

#4064 closed enhancement (wontfix)

[PATCH] New option for gdal_calc.py

Reported by: CYesson Owned by: warmerdam
Priority: low Milestone: closed_because_of_github_migration
Component: default Version: unspecified
Severity: minor Keywords:
Cc: hobu.inc@…

Description

I have implemented a new option to gdal_calc.py to deal with a specific request about processing layers of different data types.

The old version performs calculations using the native data type of the original input layers, which can be problematic if, say, you are dividing two integers and expect a float output.

The new feature --CalcAsDT will convert the input data to the output data type prior to calculation and thus bypass the above problem. I have not implemented this as the default option because of the potential hit to performance for larger files.

I have attached the new version of gdal_calc.py and a diff from the previous version

  • Chris Yesson

Attachments (3)

gdal_calc.py (12.6 KB ) - added by CYesson 13 years ago.
New version of gdal_calc.py with new option
gdal_calc.diff (1.2 KB ) - added by CYesson 13 years ago.
diff of old gdal_calc.py and new version
gdal_calc.2.py (12.5 KB ) - added by CYesson 13 years ago.
gdal_calc.py with working type option as --wt and other options changed for consistency (--ot and --of)

Download all attachments as: .zip

Change History (9)

by CYesson, 13 years ago

Attachment: gdal_calc.py added

New version of gdal_calc.py with new option

by CYesson, 13 years ago

Attachment: gdal_calc.diff added

diff of old gdal_calc.py and new version

comment:1 by Even Rouault, 13 years ago

For consistency with other utilities, I would instead suggest -ot (output type) for the name of the option, like in gdal_translate or gdalwarp, if that type is the type of the output file. If it is just an indermediate working type, -wt (working type) could be more appropriate (like in gdalwarp).

by CYesson, 13 years ago

Attachment: gdal_calc.2.py added

gdal_calc.py with working type option as --wt and other options changed for consistency (--ot and --of)

comment:2 by CYesson, 13 years ago

Thanks for the comment.

I have implemented the notation changes mentioned above for greater consistency with other gdal tools. I have used --wt for working data type and --of for format and --ot for output data type. Note that the optparse package used by gdal_calc to handle options does not accept 2 character options with the single dash "-" notation.

I have uploaded a new version of gdal_calc with these options.

comment:3 by warmerdam, 13 years ago

In terms of consistency it is not helpful to use --ot, --of and --wt instead of -ot, -of and -wt. I would suggest dispatching with optparse and doing the option processing more conventionally.

comment:4 by Jukka Rahkonen, 9 years ago

Did this process really stop to considerations about if the options should be "--ot, --of and --wt" or "-ot, -of and -wt"?

comment:5 by Jukka Rahkonen, 9 years ago

Summary: New option for gdal_calc.py[PATCH] New option for gdal_calc.py

comment:6 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.