Skip to content
Snippets Groups Projects
Commit 7ce0756c authored by Sabine Schröder's avatar Sabine Schröder
Browse files

Merge branch 'Development_Branch_Tom' into 'master'

topography_srtm now shows the value -999, if the coordinates are out of bounds for the service

See merge request !88
parents 1ec334fa 15497a12
Branches
No related tags found
1 merge request!88topography_srtm now shows the value -999, if the coordinates are out of bounds for the service
Pipeline #224245 passed
......@@ -217,19 +217,29 @@ class GeoCube:
dataset = data_array.to_dataset('band')
data_array.close()
self.dataset = dataset.rename({"x": "lon", "y": "lat"})
lat = self.dataset.variables["lat"][:]
lon = self.dataset.variables["lon"][:]
bb = [[lat.min(), lat.max()], [lon.max(), lon.min()]]
self.dataset = self.dataset.sel(lon=slice(self.lon - 5, self.lon + 5), lat=slice(self.lat + 5, self.lat - 5))
# Problem mit der lat Achse, die von + nach - geht
tmp = self.dataset[1].values.tolist()
# tmp = self.dataset[1].values.tolist()
self.xarray = True
lat = self.dataset.variables["lat"][:]
lon = self.dataset.variables["lon"][:]
min_lat = lat.min()
max_lat = lat.max()
min_lon = lon.min()
max_lon = lon.max()
try:
min_lat = lat.min()
max_lat = lat.max()
min_lon = lon.min()
max_lon = lon.max()
except:
if self.lat < bb[0][0] or self.lat > bb[0][1]:
raise ValueError(f"The given lat ({self.lat}) is out of range. Please select one between {float(bb[0][0])} and {float(bb[0][1])}")
elif self.lon < bb[1][0] or self.lon > bb[1][1]:
raise ValueError(f"The given lat ({self.lon}) is out of range. Please select one between {float(bb[1][0])} and {float(bb[1][1])}")
self.metadata['lower_corner'] = [min_lat, min_lon]
self.metadata['upper_corner'] = [max_lat, max_lon]
......@@ -304,6 +314,9 @@ class GeoCube:
dataset = data_array.to_dataset('band')
data_array.close()
self.dataset = dataset.rename({"x": "lon", "y": "lat"})
lat = self.dataset.variables["lat"][:]
lon = self.dataset.variables["lon"][:]
bb = [[lat.min(), lat.max()], [lon.max(), lon.min()]]
self.dataset = self.dataset.sel(lon=slice(self.lon - 5, self.lon + 5),
lat=slice(self.lat + 5, self.lat - 5))
......@@ -311,11 +324,16 @@ class GeoCube:
lat = self.dataset.variables["lat"][:]
lon = self.dataset.variables["lon"][:]
min_lat = lat.min()
max_lat = lat.max()
min_lon = lon.min()
max_lon = lon.max()
try:
min_lat = lat.min()
max_lat = lat.max()
min_lon = lon.min()
max_lon = lon.max()
except:
if self.lat < bb[0][0] or self.lat > bb[0][1]:
raise ValueError(f"The given lat ({self.lat}) is out of range. Please select one between {float(bb[0][0])} and {float(bb[0][1])}")
elif self.lon < bb[1][0] or self.lon > bb[1][1]:
raise ValueError(f"The given lat ({self.lon}) is out of range. Please select one between {float(bb[1][0])} and {float(bb[1][1])}")
self.metadata['lower_corner'] = [min_lat, min_lon]
self.metadata['upper_corner'] = [max_lat, max_lon]
......@@ -338,9 +356,9 @@ class GeoCube:
f"/mnt/geodata/topography/SRTMv4.1/6_5x5_TIFs/srtm_{lon_index}_{lat_index}.tif")
except:
coords = {'lat': [self.lat - 1, self.lat, self.lat + 1], 'lon': [self.lon - 1, self.lon, self.lon + 1]}
data = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
data = [[-999, -999, -999],
[-999, -999, -999],
[-999, -999, -999]]
self.dataset = xr.Dataset({1: (['lat', 'lon'], data)}, coords=coords)
else:
dataset = data_array.to_dataset('band')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment