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

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

@vincent-26

Description

@vincent-26

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions