Passing Glob.Glob through gdal

I have a folder that contains several folders. The sub folders contain each of the following, one or more .csv files and one .tif file. What I am trying to do is grab one of the .csv files and the .tif. The .tif will be used with the GetGeoTransform() function and the .csv will provide column and row values to ultimately output coordinates (The .csv files contain column and row data from the relative tif. I understand the issue that glob.glob returns a class type list and gdal.Open() requires it to be in string format. I initally tried relative_tif_file = str(glob.glob(path_tif + '/*.tif'), but that doesn't work because it is still in a list format.

Any suggestions on how to get around this?

Folder
    subfolder1
        1.csv
        2.csv
        3.csv
        1.tif
    subfolder2
        1.csv
        1.tif
...
root = 'D:/data/export_csv2/'

for i in os.listdir(root):
    path_csv = root + str(i)
    path_tif = root + str(i)
    all_csv_files = glob.glob(path_csv + '/*.csv')
    relative_tif_file = glob.glob(path_tif + '/*.tif')
    ds = gdal.Open(relative_tif_file)
    c, a, b, f, d, e = ds.GetGeoTransform()
RuntimeError: not a string


from Recent Questions - Stack Overflow https://ift.tt/3oop4A5
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations