Skip to content

Instantly share code, notes, and snippets.

@m-root
Last active September 2, 2023 10:53
Show Gist options
  • Save m-root/7bdd5c598b767dd2684e77b586bc3ffd to your computer and use it in GitHub Desktop.
Save m-root/7bdd5c598b767dd2684e77b586bc3ffd to your computer and use it in GitHub Desktop.
Extract data from multiple gifs
import os
import rasterio
import pandas as pd
folder_path = "/path/to/your/folder"
all_tiffs = [f for f in os.listdir(folder_path) if f.endswith('.tif') or f.endswith('.tiff')]
master_df = pd.DataFrame()
for tiff_file in all_tiffs:
file_path = os.path.join(folder_path, tiff_file)
with rasterio.open(file_path) as src:
data = src.read(1)
df = pd.DataFrame(data)
# Additional operations as needed...
# For this example, we'll just concatenate each DataFrame
master_df = pd.concat([master_df, df], axis=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment