Skip to content

Commit

Permalink
added hillshade preview to hirise, added todo to pedr4align_moody to …
Browse files Browse the repository at this point in the history
…fix issue with get_srs_info
  • Loading branch information
AndrewAnnex committed Jun 28, 2021
1 parent 4c79af7 commit b688fe4
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
6 changes: 5 additions & 1 deletion asap_stereo/asap.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def get_pedr_4_pcalign_w_moody(self, cub_path, proj = None, https=True):
projection = self.get_srs_info(cub_path, use_eqc=proj)
print(projection)
# reproject to image coordinates for some gis tools
# todo: this fails sometimes on the projection string, a proj issue... trying again in command line seems to fix it
sh.ogr2ogr('-t_srs', projection, '-sql', sql_query, f'./{out_name}_pedr4align.shp', shpfile.name)

@rich_logger
Expand Down Expand Up @@ -671,6 +672,9 @@ def rescale_and_overwrite(self, factor, postfix='.lev1eo.cub'):
self.rescale_cub(f'{right}{postfix}', factor=factor, overwrite=True)

def get_pedr_4_pcalign_common(self, postfix, proj, https, pedr_list=None):
if postfix.endswith('.cub'):
warnings.warn(f'pedr4pcalign_common provided postfix of {postfix}, which should not end with .cub! Removing for you..')
postfix = postfix[:-4]
left, right, both = self.parse_stereopairs()
with cd(Path.cwd() / both):
if pedr_list:
Expand Down Expand Up @@ -1431,7 +1435,7 @@ def pre_step_ten(self, refdem, alignment_method='translation', do_resample='gdal
return cmd_res

@rich_logger
def pre_step_ten_pedr(self, pedr_list=None, postfix='_RED.map.cub'):
def pre_step_ten_pedr(self, pedr_list=None, postfix='_RED.map'):
"""
Use MOLA PEDR data to align the HiRISE DEM to in case no CTX DEM is available
Expand Down
56 changes: 55 additions & 1 deletion asap_stereo/asap_hirise_workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"source": [
"from IPython.display import Image\n",
"from asap_stereo import asap\n",
"import math"
"import math\n",
"from pathlib import Path"
]
},
{
Expand Down Expand Up @@ -382,6 +383,59 @@
"Image(filename=out)"
]
},
{
"cell_type": "markdown",
"source": [
"## Hillshade of low res DEM"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"both = f'{left}_{right}'\n",
"img = str(next(Path(f'./{both}/results_ba/dem/').glob(f'{both}_*DEM.tif')))\n",
"out = img.replace('.tif','_h.png')"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"!gdaldem hillshade {img} {out}"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"Image(filename=out)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"metadata": {
Expand Down

0 comments on commit b688fe4

Please sign in to comment.