Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Applying function to all files in directory using PyQGIS/Python? #87

Open
vincent-26 opened this issue Mar 8, 2019 · 0 comments
Open

Comments

@vincent-26
Copy link

Hello everyone how can I apply this function to all files in folder?
The function in question extracts the bands from a raster file (.ecw) and I would like to be able to do it to all the files in folder.
What should I do?

import gdal

in_path = "C:/gis_data/ECW"
out_path ="C:/gis_data/output"

src_ds = gdal.Open(in_path)

for i in range(1,src_ds.RasterCount+1):
    out_ds = gdal.Translate(out_path + 'test' + str(i) + '.ecw', src_ds, format='GTiff', bandList=[i])
    out_ds=None
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant