#%% from pathlib import Path import pandas as pd import rasterio from rasterio.warp import transform_bounds #%% # IMPORTS DATA_FOLDER = Path("/home/sabrina/Documents/Tese/05_Dataset/MatchGeo-DEM-v1/data") REGIONS = {'ATA_MV', 'BRA_SP', 'CHN_WS', 'ESP_EH', 'FIN_LM', 'GER_BN', 'IDN_SV', 'KAZ_AC', 'KSA_WA', 'NAM_HF', 'NZL_KP', 'PHL_TA', 'USA_GC'} #%% dict_profile = { "region": [], "file_size_mb": [], "nodata": [], "crs": [], "dtype": [], "resolution":[], "width": [], "heigth": [], "n_tiles": [], "tile_size": [], "x_min": [], "x_max": [], "y_min": [], "y_max": [], "long_min": [], "long_max": [], "lat_min": [], "lat_max": [], } #%% for region in REGIONS: # Get merged file size tif_path = Path(DATA_FOLDER, f"{region}/{region}.tif") file_size = tif_path.stat().st_size / (10**6) # Get raster profile and bounds with rasterio.open(tif_path) as src: profile = src.profile bounds = src.bounds try: lonlat_bounds = transform_bounds(src.crs, "EPSG:4326", *bounds) except: lonlat_bounds = transform_bounds("EPSG:25832", "EPSG:4326", *bounds) # Get number of tiles tile_path = Path(DATA_FOLDER, f"{region}/tiles") n_tiles = len(list(tile_path.glob("*.tif"))) # Get tile size tile0 = list(tile_path.glob("*.tif"))[0] with rasterio.open(tile0) as src: tile_size = src.width # Update dictionary dict_profile['region'].append(region) dict_profile['file_size_mb'].append(file_size) dict_profile['nodata'].append(profile.get('nodata')) dict_profile['crs'].append(str(profile['crs'])) dict_profile['dtype'].append(profile['dtype']) dict_profile['resolution'].append(profile['transform'][0]) dict_profile['width'].append(profile['width']) dict_profile['heigth'].append(profile['height']) dict_profile['n_tiles'].append(n_tiles) dict_profile['tile_size'].append(tile_size) dict_profile['x_min'].append(bounds.left) dict_profile['x_max'].append(bounds.right) dict_profile['y_min'].append(bounds.bottom) dict_profile['y_max'].append(bounds.top) dict_profile['long_min'].append(lonlat_bounds[0]) dict_profile['long_max'].append(lonlat_bounds[2]) dict_profile['lat_min'].append(lonlat_bounds[1]) dict_profile['lat_max'].append(lonlat_bounds[3]) #%% # Create DataFrame df = pd.DataFrame(dict_profile) print(df) # %% df.to_csv(Path(DATA_FOLDER, "metadadata.csv")) # %%