Last active
September 2, 2023 10:53
-
-
Save m-root/7bdd5c598b767dd2684e77b586bc3ffd to your computer and use it in GitHub Desktop.
Extract data from multiple gifs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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