agrenott / pyhgtmap

Generate OSM contour lines from NASA SRTM (or other digital elevation model sources) data
GNU General Public License v2.0
13 stars 3 forks source link

Problems with a few files from SRTM1 #56

Open keenonkites opened 6 months ago

keenonkites commented 6 months ago

Hi,

we ran into a new problem with SRTM1 files: some 'downloaded' files do not contain a valid geotiff file but are json files that look like the answer from the download service.

The json files contain:


{"errorMessage":"Invalid scene or product","isPending":false,"url":null}```

And the exception thrown on maps containing problematic tiles look like:
```N46E050: using file ./hgt/SRTM1v3.0/N46E050.tif.
  File "/home/xxx/miniconda3/bin/pyhgtmap", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/xxx/miniconda3/lib/python3.12/site-packages/pyhgtmap/main.py", line 67, in main
    main_internal(sys.argv[1:])
  File "/home/xxx/miniconda3/lib/python3.12/site-packages/pyhgtmap/main.py", line 59, in main_internal
    HgtFilesProcessor(opts.nJobs, opts.startId, opts.startWayId, opts).process_files(
  File "/home/xxx/miniconda3/lib/python3.12/site-packages/pyhgtmap/hgt/processor.py", line 291, in process_files
    self.try_parallelizing(self.process_file, file_name, check_poly)
  File "/home/xxx/miniconda3/lib/python3.12/site-packages/pyhgtmap/hgt/processor.py", line 221, in try_parallelizing
    func(*args, **kwargs)
  File "/home/xxx/miniconda3/lib/python3.12/site-packages/pyhgtmap/hgt/processor.py", line 232, in process_file
    hgt_file = HgtFile(
               ^^^^^^^^
  File "/home/xxx/miniconda3/lib/python3.12/site-packages/pyhgtmap/hgt/file.py", line 425, in __init__
    self.init_as_geotiff(
  File "/home/xxx/miniconda3/lib/python3.12/site-packages/pyhgtmap/hgt/file.py", line 518, in init_as_geotiff
    g: gdal.Dataset = gdal.Open(self.fullFilename)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/miniconda3/lib/python3.12/site-packages/osgeo/gdal.py", line 4716, in Open
    return _gdal.Open(*args)
           ^^^^^^^^^^^^^^^^^
RuntimeError: `./hgt/SRTM1v3.0/N44E048.tif' not recognized as a supported file format.```

Problematic Tiles I've identified so far (for you to test) are:
- N38E050.tif: JSON data
- N38E051.tif: JSON data
- N39E050.tif: JSON data
- N39E051.tif: JSON data
- N41E050.tif: JSON data
- N42E049.tif: JSON data 
- N43E048.tif: JSON data
- N44E048.tif: JSON data
- N44E049.tif: JSON data
- N50E015.tif: JSON data

If you use the following poly file to build the srtm1 contour data you can also reproduce it:
https://download.geofabrik.de/asia/azerbaijan.poly

N42E049.tif is the tile that throws the exception on Azerbaijan.

If you need more information, just let me know. Happy to help and run additional tests.

Cheers Patrik
agrenott commented 6 months ago

Hi, Thanks for the detailed report, as usual :). I've started re-engineering the SRTM to the new source plugin framework (cleaning the old messy code). I'll take this case into account.