Skip to content

Commit

Permalink
Fixed AW3D30 v3.1 new file names (Issue #1)
Browse files Browse the repository at this point in the history
Fixed small bug in gpxsrtm.py
  • Loading branch information
mrihtar committed Jan 14, 2022
1 parent 219f845 commit ab381bf
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 38 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ downloaded data must first be converted to internal Python representation
Preprocessing of data also takes care of possible voids detected in data
(*yes, some tiles may still contain voids!*) with the built-in interpolation
(griddata/linear <sup>[LNDI]</sup>) and extrapolation (k-NN/12 neighbours
<sup>[CKDT]</sup>).
<sup>[cKDT]</sup>).

Example of preprocessing a tile with voids:
```
Expand All @@ -77,7 +77,7 @@ dataset obtained by resampling of the 5-meter mesh version of the
[World 3D Topographic Data], which is considered to be the most precise
global-scale elevation data at this time.

Current version (v2.2) released in April 2019 is an improved version with
Current version (v3.2) released in January 2022 is an improved version with
all data voids filled. It's available for download at [AW3D30 DSM data map]
after registration with e-mail confirmation.

Expand All @@ -96,16 +96,16 @@ column and line (right and above) from surrounding tiles to be the same size
as SRTM matrix. This can be done with the supplied tool **`extpia.py`**:

```
$ extpia.py N046E015_AVE_DSM.pickle
Reading N046E015_AVE_DSM.pickle
Reading N046E016_AVE_DSM.pickle
Reading N047E015_AVE_DSM.pickle
Reading N047E016_AVE_DSM.pickle
Writing N046E015_AVE_EXT.pickle
$ extpia.py ALPSMLC30_N046E015_DSM.pickle
Reading ALPSMLC30_N046E015_DSM.pickle
Reading ALPSMLC30_N046E016_DSM.pickle
Reading ALPSMLC30_N047E015_DSM.pickle
Reading ALPSMLC30_N047E016_DSM.pickle
Writing ALPSMLC30_N046E015_EXT.pickle
```

The resulting `N046E015_AVE_EXT.pickle` is of size 3601 x 3601 and is ready to
be used for GPX elevation update.
The resulting `ALPSMLC30_N046E015_EXT.pickle` is of size 3601 x 3601 and is
ready to be used for GPX elevation update.

### GPX elevation update

Expand Down Expand Up @@ -171,7 +171,7 @@ You can also print the data matrix as tab separated values with
[Shuttle Radar Topography Mission]: https://www2.jpl.nasa.gov/srtm/mission.htm
[ALOS World 3D-30m (AW3D30)]: https://www.eorc.jaxa.jp/ALOS/en/dataset/aw3d_e.htm
[World 3D Topographic Data]: https://www.aw3d.jp/en/
[JPL Release 2014-321]: https://www.jpl.nasa.gov/news/news.php?release=2014-321
[JPL Release 2014-321]: https://www.jpl.nasa.gov/news/us-releases-enhanced-shuttle-land-elevation-data
[USGS EarthExplorer]: http://earthexplorer.usgs.gov
[AW3D30 DSM data map]: https://www.eorc.jaxa.jp/ALOS/en/aw3d30/data/index.htm
[Digital Terrain Elevation Data (DTED)]: https://www.dlr.de/eoc/en/Portaldata/60/Resources/dokumente/7_sat_miss/SRTM-XSAR-DEM-DTED-1.1.pdf
Expand All @@ -184,4 +184,4 @@ You can also print the data matrix as tab separated values with
[Bilinear interpolation]: https://en.wikipedia.org/wiki/Bilinear_interpolation
[Inverse Distance Weighting (IDW) interpolation]: https://en.wikipedia.org/wiki/Inverse_distance_weighting
[LNDI]: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.LinearNDInterpolator.html
[CKDT]: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.cKDTree.html
[cKDT]: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.cKDTree.html
31 changes: 16 additions & 15 deletions extpia.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
prog_ver = 'extpia v1.4 Copyright (c) 2019-2020 Matjaz Rihtar'
prog_ver = 'extpia v1.5 Copyright (c) 2019-2022 Matjaz Rihtar'
# py_ver = sys.version_info.major
import sys, os, glob, re
import ntpath, argparse
Expand Down Expand Up @@ -112,9 +112,10 @@ def procfile(fpath):
sys.stderr.write('Nothing to be done for SRTM data\n')
return rc

lat0 = int(fn[0][1:4])
# ALOS AW3D30 v3.1 file name format: ALPSMLC30_N046E015_DSM.tif
lat0 = int(fn[1][1:4])
if fn[0][0].startswith('S'): lat0 = -lat0
lon0 = int(fn[0][5:8])
lon0 = int(fn[1][5:8])
if fn[0][4].startswith('W'): lon0 = -lon0

fns = []
Expand All @@ -126,23 +127,23 @@ def procfile(fpath):
alat0 = abs(lat0)
if lon0 < 0: # fn[0][4] == 'W'
alon0 = abs(lon0)
fns[1]['name'] = '{}S{:03d}W{:03d}_AVE_DSM.pickle'.format(fdir, alat0, alon0-1)
fns[2]['name'] = '{}S{:03d}W{:03d}_AVE_DSM.pickle'.format(fdir, alat0-1, alon0)
fns[3]['name'] = '{}S{:03d}W{:03d}_AVE_DSM.pickle'.format(fdir, alat0-1, alon0-1)
fns[1]['name'] = '{}ALPSMLC30_S{:03d}W{:03d}_DSM.pickle'.format(fdir, alat0, alon0-1)
fns[2]['name'] = '{}ALPSMLC30_S{:03d}W{:03d}_DSM.pickle'.format(fdir, alat0-1, alon0)
fns[3]['name'] = '{}ALPSMLC30_S{:03d}W{:03d}_DSM.pickle'.format(fdir, alat0-1, alon0-1)
else: # fn[0][4] == 'E'
fns[1]['name'] = '{}S{:03d}E{:03d}_AVE_DSM.pickle'.format(fdir, alat0, lon0+1)
fns[2]['name'] = '{}S{:03d}E{:03d}_AVE_DSM.pickle'.format(fdir, alat0-1, lon0)
fns[3]['name'] = '{}S{:03d}E{:03d}_AVE_DSM.pickle'.format(fdir, alat0-1, lon0+1)
fns[1]['name'] = '{}ALPSMLC30_S{:03d}E{:03d}_DSM.pickle'.format(fdir, alat0, lon0+1)
fns[2]['name'] = '{}ALPSMLC30_S{:03d}E{:03d}_DSM.pickle'.format(fdir, alat0-1, lon0)
fns[3]['name'] = '{}ALPSMLC30_S{:03d}E{:03d}_DSM.pickle'.format(fdir, alat0-1, lon0+1)
else: # fn[0][0] == 'N'
if lon0 < 0: # fn[0][4] == 'W'
alon0 = abs(lon0)
fns[1]['name'] = '{}N{:03d}W{:03d}_AVE_DSM.pickle'.format(fdir, lat0, alon0-1)
fns[2]['name'] = '{}N{:03d}W{:03d}_AVE_DSM.pickle'.format(fdir, lat0+1, alon0)
fns[3]['name'] = '{}N{:03d}W{:03d}_AVE_DSM.pickle'.format(fdir, lat0+1, alon0-1)
fns[1]['name'] = '{}ALPSMLC30_N{:03d}W{:03d}_DSM.pickle'.format(fdir, lat0, alon0-1)
fns[2]['name'] = '{}ALPSMLC30_N{:03d}W{:03d}_DSM.pickle'.format(fdir, lat0+1, alon0)
fns[3]['name'] = '{}ALPSMLC30_N{:03d}W{:03d}_DSM.pickle'.format(fdir, lat0+1, alon0-1)
else: # fn[0][4] == 'E'
fns[1]['name'] = '{}N{:03d}E{:03d}_AVE_DSM.pickle'.format(fdir, lat0, lon0+1)
fns[2]['name'] = '{}N{:03d}E{:03d}_AVE_DSM.pickle'.format(fdir, lat0+1, lon0)
fns[3]['name'] = '{}N{:03d}E{:03d}_AVE_DSM.pickle'.format(fdir, lat0+1, lon0+1)
fns[1]['name'] = '{}ALPSMLC30_N{:03d}E{:03d}_DSM.pickle'.format(fdir, lat0, lon0+1)
fns[2]['name'] = '{}ALPSMLC30_N{:03d}E{:03d}_DSM.pickle'.format(fdir, lat0+1, lon0)
fns[3]['name'] = '{}ALPSMLC30_N{:03d}E{:03d}_DSM.pickle'.format(fdir, lat0+1, lon0+1)

for ii in range(4):
fpath_ = fns[ii]['name']
Expand Down
15 changes: 8 additions & 7 deletions gpxsrtm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
prog_ver = 'gpxsrtm v1.16 Copyright (c) 2019-2020 Matjaz Rihtar'
prog_ver = 'gpxsrtm v1.17 Copyright (c) 2019-2022 Matjaz Rihtar'
# py_ver = sys.version_info.major
import sys, os, glob, re
import ntpath, argparse
Expand Down Expand Up @@ -299,8 +299,9 @@ def get_elev(point, it='bil'):
#Z = np.array([[elev1, np.nan, elev2], [np.nan, elev, np.nan], [elev3, np.nan, elev4]])
#plot_elev(X, Y, Z, it)

diff = elev - point.elevation
#print('Point at ({:.7f},{:.7f}), elev: {:.2f}, elev_{}: {:.2f}, diff: {:.2f}'.format(lat, lon, point.elevation, it, elev, diff))
if point.elevation is not None:
diff = elev - point.elevation
#print('Point at ({:.7f},{:.7f}), elev: {:.2f}, elev_{}: {:.2f}, diff: {:.2f}'.format(lat, lon, point.elevation, it, elev, diff))
except:
exc_type, exc_obj, exc_tb = sys.exc_info()
exc = traceback.format_exception_only(exc_type, exc_obj)
Expand Down Expand Up @@ -398,23 +399,23 @@ def procfile(gpxname):
if source == 'srtm':
fname = 's{:02d}_w{:03d}_1arc_v3.pickle'.format(alat, alon)
else: # alos
fname = 'S{:03d}W{:03d}_AVE_EXT.pickle'.format(alat, alon)
fname = 'ALPSMLC30_S{:03d}W{:03d}_EXT.pickle'.format(alat, alon)
else:
if source == 'srtm':
fname = 's{:02d}_e{:03d}_1arc_v3.pickle'.format(alat, lon)
else: # alos
fname = 'S{:03d}E{:03d}_AVE_EXT.pickle'.format(alat, lon)
fname = 'ALPSMLC30_S{:03d}E{:03d}_EXT.pickle'.format(alat, lon)
else:
if lon < 0:
if source == 'srtm':
fname = 'n{:02d}_w{:03d}_1arc_v3.pickle'.format(lat, alon)
else: # alos
fname = 'N{:03d}W{:03d}_AVE_EXT.pickle'.format(lat, alon)
fname = 'ALPSMLC30_N{:03d}W{:03d}_EXT.pickle'.format(lat, alon)
else:
if source == 'srtm':
fname = 'n{:02d}_e{:03d}_1arc_v3.pickle'.format(lat, lon)
else: # alos
fname = 'N{:03d}E{:03d}_AVE_EXT.pickle'.format(lat, lon)
fname = 'ALPSMLC30_N{:03d}E{:03d}_EXT.pickle'.format(lat, lon)

if datadir == '<prog>{}data'.format(os.sep):
fpath = '{}data{}{}'.format(where, os.sep, fname)
Expand Down
2 changes: 1 addition & 1 deletion json2pickle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
prog_ver = 'json2pickle v1.1 Copyright (c) 2019-2020 Matjaz Rihtar'
prog_ver = 'json2pickle v1.1 Copyright (c) 2019-2022 Matjaz Rihtar'
import sys, os
import ntpath
import traceback
Expand Down
2 changes: 1 addition & 1 deletion pickle2json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
prog_ver = 'pickle2json v1.1 Copyright (c) 2019-2020 Matjaz Rihtar'
prog_ver = 'pickle2json v1.1 Copyright (c) 2019-2022 Matjaz Rihtar'
import sys, os
import ntpath
import traceback
Expand Down
2 changes: 1 addition & 1 deletion prepare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
prog_ver = 'prepare v1.12 Copyright (c) 2019-2020 Matjaz Rihtar'
prog_ver = 'prepare v1.12 Copyright (c) 2019-2022 Matjaz Rihtar'
# py_ver = sys.version_info.major
import sys, os, glob, re
import ntpath, argparse
Expand Down
2 changes: 1 addition & 1 deletion printdata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
prog_ver = 'printdata v1.1 Copyright (c) 2019-2020 Matjaz Rihtar'
prog_ver = 'printdata v1.1 Copyright (c) 2019-2022 Matjaz Rihtar'
import sys, os, glob
import ntpath, argparse
import traceback
Expand Down

0 comments on commit ab381bf

Please sign in to comment.