diff --git a/grompy/check_files.py b/grompy/check_files.py index 94999898c7466b6f19895469cfad1ba03ef4e9c4..3a5e9d52e3ae91c8436db1dcd35771eafacbd6f0 100644 --- a/grompy/check_files.py +++ b/grompy/check_files.py @@ -58,10 +58,16 @@ def check_parcel_info(grompy_yaml, counts_file_10m, counts_file_20m, counts_file if fname_shape_file.exists(): gdf = gpd.read_file(fname_shape_file, rows=1) for column in ["fieldid", "year", "cat_gewasc", "gws_gewasc", "gws_gewas", "provincie", - "gemeente", "regio", "PC4", "woonplaats", "waterschap", "S2_Tiles", "AHN2"]: + "gemeente", "regio", "PC4", "woonplaats", "waterschap", "AHN2"]: if column not in gdf.columns: print(f"ERROR: Attribute {column} missing in BRP shapefile") ALL_CHECKS_OK = False + # Check if either S2_tiles or S2tiles exist because there were two variants in the shapefiles + if "S2_Tiles" in gdf.columns or "S2Tiles" in gdf.columns: + pass + else: + print(f"ERROR: Attribute 'S2Tiles' or 'S2_Tiles' is missing in BRP shapefile") + ALL_CHECKS_OK = False gpkg_fname_fp = make_path_absolute(grompy_yaml, Path(gpkg_fname)) diff --git a/grompy/dap.py b/grompy/dap.py index 665809e052cb53402f8a576f65f3fd3a2d2330a3..660f30d32be53b7704b630c34412ea0666d7f265 100644 --- a/grompy/dap.py +++ b/grompy/dap.py @@ -228,7 +228,8 @@ class DataAccessProvider: df = self._add_S2_angles(df, parcel_info) df.index = pd.to_datetime(df.day) df.drop(columns="day", inplace=True) - df[self.bands2convert] = df[self.bands2convert].astype(float) / 10000.0 + if dataset_name.startswith("sentinel2"): + df[self.bands2convert] = df[self.bands2convert].astype(float) / 10000.0 d[dataset_name] = df c = SimpleNamespace(**d) diff --git a/grompy/load_data.py b/grompy/load_data.py index 6da6cf4bad0974e82475a70a969fc32f6fdfb2fe..a27d2f53a9a17d5fd8e1879b20313cc431685c23 100644 --- a/grompy/load_data.py +++ b/grompy/load_data.py @@ -43,6 +43,12 @@ def load_parcel_info(grompy_yaml, gpkg_fname, counts_file_10m, counts_file_20m, df["fieldid"] = df.fieldid.astype(np.int32) df = df.set_index("fieldid") + # Check for S2Tiles/S2_Tiles column + if "S2_Tiles" in df.columns: + pass + else: + df["S2_Tiles"] = df.S2Tiles + # Compute latitude/longitude of field centroids r = [] for row in df.itertuples():