Opened 10 years ago
Closed 5 years ago
#5548 closed enhancement (wontfix)
[FEATURE] add --asarray option to gdal_calc.py, which will enable it to handle more than 26 input files and simplify its usage
Reported by: | xg1990 | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | closed_because_of_github_migration |
Component: | Utilities | Version: | unspecified |
Severity: | normal | Keywords: | gdal |
Cc: |
Description
When the option --asarray is toggled, value of the input files will be stored in a list named A
like this:
[
[ value_of_Dataset1_Band1, value_of_Dataset1_Band2, ..., ]
[ value_of_Dataset2_Band1, value_of_Dataset2_Band2, ..., ]
....
[ value_of_Datasetn_Band1, value_of_Datasetn_Band2, ..., ]
]
Besides, all the trailing arguments will be treated as input files. And the alpha list is not necessary any more.
For example, user can calculate the maximum of the 1st band of all the TIFF files in some folder by:
gdal_calc.py --asarray --calc="numpy.max([a[0] for a in A])" ./some_folder/*.tif
or calculate the average of all the bands by:
gdal_calc.py --asarray --calc="sum([sum(a) for a in A]) / sum([len(a) for a in A])" ./some_folder/*.tif
Simple operation such as addition is also possible:
gdal_calc.py --asarray --calc="A[0][0] + A[1][0]" F1.tif F2.tif
Most importantly, many numpy functions can be useful now.
Attachments (2)
Change History (7)
by , 10 years ago
Attachment: | gdal_calc.py.patch added |
---|
by , 10 years ago
Attachment: | gdal_calc.py added |
---|
follow-up: 3 comment:1 by , 10 years ago
Cc: | added |
---|
It would also be necessary to enhance swig/python/scripts/gdal_calc.dox and autotest/pyscripts/test_gdal_calc.py
comment:2 by , 10 years ago
Cc: | removed |
---|
sorry Even I don't have time to look into this, in fact I will be unavailable for a pretty long time.
comment:3 by , 10 years ago
Replying to rouault:
It would also be necessary to enhance swig/python/scripts/gdal_calc.dox and autotest/pyscripts/test_gdal_calc.py
Maybe I can help. But I'm not sure what to do with them.
comment:4 by , 9 years ago
Related discussion in the gdal-dev list: http://thread.gmane.org/gmane.comp.gis.gdal.devel/40781
comment:5 by , 5 years ago
Milestone: | → closed_because_of_github_migration |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
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.
This is the modified file