Skip to content

Commit 8eaa7a5

Browse files
committed
solving map projection issue
1 parent 7dd87e7 commit 8eaa7a5

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

ost/Project.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
# ------ bug of rasterio --------
5+
import os
6+
if "GDAL_DATA" in list(os.environ.keys()):
7+
del os.environ["GDAL_DATA"]
8+
if "PROJ_LIB" in list(os.environ.keys()):
9+
del os.environ["PROJ_LIB"]
10+
# ------ bug of rasterio --------
11+
412
import json
513
import urllib.request
614
import urllib.parse

ost/generic/common_wrappers.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import logging
55
from retrying import retry
6-
76
from rasterio.crs import CRS
87

98
from ost.helpers import helpers as h
@@ -189,14 +188,15 @@ def terrain_correction(infile, outfile, logfile, config_dict):
189188
cpus = config_dict['snap_cpu_parallelism']
190189

191190
# auto projections of snap
192-
# if 42001 <= dem_dict['out_projection'] <= 97002:
193-
# projection = f"AUTO:{dem_dict['out_projection']}"
191+
if 42001 <= dem_dict['out_projection'] <= 97002:
192+
projection = f"AUTO:{dem_dict['out_projection']}"
194193
# epsg codes
195-
# else:
196-
# projection = f"EPSG:{dem_dict['out_projection']}"
194+
elif int(dem_dict['out_projection']) == 4326:
195+
projection = CRS.from_epsg(4326).to_wkt()
196+
else:
197+
projection = f"EPSG:{dem_dict['out_projection']}"
197198

198-
projection = CRS.from_epsg(dem_dict['out_projection']).to_wkt()
199-
#projection = 'GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]]'
199+
#
200200
logger.debug('Geocoding product.')
201201

202202
if ard['geocoding'] == 'terrain':
@@ -211,7 +211,7 @@ def terrain_correction(infile, outfile, logfile, config_dict):
211211
f"-PimgResamplingMethod=\'{dem_dict['image_resampling']}\' "
212212
f"-PpixelSpacingInMeter={ard['resolution']} "
213213
f"-PalignToStandardGrid=true "
214-
#f"-PmapProjection=\'{projection}\' "
214+
f"-PmapProjection=\'{projection}\' "
215215
f"-t \'{str(outfile)}\' \'{str(infile)}\' "
216216
)
217217
elif ard['geocoding'] == 'ellipsoid':
@@ -226,7 +226,7 @@ def terrain_correction(infile, outfile, logfile, config_dict):
226226
f"-PimgResamplingMethod=\'{dem_dict['image_resampling']}\' "
227227
f"-PpixelSpacingInMeter={ard['resolution']} "
228228
f"-PalignToStandardGrid=true "
229-
#f"-PmapProjection=\'{projection}\' "
229+
f"-PmapProjection=\'{projection}\' "
230230
f"-t \'{str(outfile)}\' \'{str(infile)}\' "
231231
)
232232
else:
@@ -276,6 +276,8 @@ def ls_mask(infile, outfile, logfile, config_dict):
276276
if 42001 <= dem_dict['out_projection'] <= 97002:
277277
projection = f"AUTO:{dem_dict['out_projection']}"
278278
# epsg codes
279+
elif int(dem_dict['out_projection']) == 4326:
280+
projection = CRS.from_epsg(4326).to_wkt()
279281
else:
280282
projection = f"EPSG:{dem_dict['out_projection']}"
281283

ost/helpers/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def get_gpt():
240240
'choices': [i for i in range(3, 27, 2)]},
241241
'scale_size': {'type': int, 'choices': range(0, 2)},
242242
'create_ls_mask': {'type': bool},
243-
'dem_name': {'type': str, 'choices': ['SRTM 1Sec HGT', 'SRTM 3Sec', 'Aster 1sec GDEM', 'GETASSE30', 'External DEM']},
243+
'dem_name': {'type': str, 'choices': ['Copernicus 30m Global DEM', 'Copernicus 90m Global DEM', 'SRTM 1Sec HGT', 'SRTM 3Sec', 'Aster 1sec GDEM', 'GETASSE30', 'External DEM']},
244244
'dem_file': {'type': str},
245245
'dem_nodata': {'type': int, 'choices': range(0, 66000)},
246246
'dem_resampling': {'type': str,

ost/s1/s1scene.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
based on a ARD product type.
1313
"""
1414

15+
# ------ bug of rasterio --------
1516
import os
17+
if "GDAL_DATA" in list(os.environ.keys()):
18+
del os.environ["GDAL_DATA"]
19+
if "PROJ_LIB" in list(os.environ.keys()):
20+
del os.environ["PROJ_LIB"]
21+
# ------ bug of rasterio --------
22+
1623
import sys
1724
import json
1825
import logging

0 commit comments

Comments
 (0)