1

I'm quite new to GIS format and conversions, so be patient with a newbie. I got stuck on a file conversion and I'm looking for some help this to fix my scripts. I have a big 5 GB tif file with a precision of 5 meters and these features:

Dimensions X: 27176 Y:.49586 Band: 1 Origin 555121,4.4447e+06 Pixel dimension 5,-5 No value:-9999 AREA_OR_POINT=Area STATISTICS_MAXIMUM=2237.2060546875 STATISTICS_MEAN=520.43425935058 STATISTICS_MINIMUM=-2.8499999046326 STATISTICS_STDDEV=429.22835999081 Data type: Float32 +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs Layer extension (original layer projection) 555120.6040000000502914,4196769.7539999997243285 : 691000.6040000000502914,4444699.7539999997243285

I'm getting that each hgt file covers 1 degree lat and 1 degree lon, and has to have a size of 1201x1201.

My intent is to convert this single tif into one or more hgt files. I suppose that given the tif dimensions (X: 27176 Y:.49586) I have first to split into multiple tif files and then convert into multiple hgt file. To do this I'm using GDAL scripts from QGIS:

enter image description here

If I try a direct conversion to hgt I get this warning and error:

Warning 1: The corner coordinates of the source are not properly aligned on plain latitude/longitude boundaries. ERROR 1: Image dimensions should be 1201x1201, 3601x3601 or 1801x3601.

So I defined these scripts below:

Step 1:

gdalwarp -of GTiff -srcnodata 32767 -t_srs "+proj=utm +zone=33 +datum=WGS84" -rcs -order 3 -ts 1201 1201 -multi C:/Users/C012426/Desktop/geocoding/5m_33N/DEM_5m_33N.tif C:/Users/C012426/Desktop/geocoding/5m_33N/DEM_5m_33N_warped.tif

Step 2:

gdal_translate -of SRTMHGT C:/Users/C012426/Desktop/geocoding/5m_33N/DEM_5m_33N_warped.tif C:/Users/C012426/Desktop/geocoding/5m_33N/DEM_5m_33N_warped.hgt

What I get instead is one file only named: N4196770E55.hgt

while I was expecting to get 27176 / 2101 = about 22 hgt files...

What is wrong in my theory and most of all in my scripts ?

7
  • You must also define the extents of each tile to match with the definition dds.cr.usgs.gov/srtm/version2_1/Documentation/Quickstart.pdf
    – user30184
    Oct 3, 2017 at 19:12
  • Thanks @user30184, as I'm in SRTM3 zone of the world, it should be 1201x1201, but I can set these in the scripts ? Oct 3, 2017 at 20:52
  • It is not only to set output into 1201x1201 but you must set also the input, the region you want to store into each file. With gdal_translate that is set with -projwin. And then the same thing again for all your about 22 regions.
    – user30184
    Oct 3, 2017 at 21:24
  • Thanks again @user30184, unfortunately I can write just java code, while GDAL APIs seem to be for other languages. Last question: are you aware of any tool able to do the splitting of the tif into smaller tif files ? Oct 3, 2017 at 22:18
  • GDAL has java bindings. I know tile cutting tools but not any that knows out-of-the box how to cut hgt tiles.
    – user30184
    Oct 4, 2017 at 4:37

1 Answer 1

1

After some researches I found that I can do tif splitting via ArcGIS, py console:

enter image description here

Then i will have to translate all tif files to HGT but this look like an half of the problem.

Script is:

import arcpy arcpy.SplitRaster_management("C:/Users/Desktop/geocoding/DEM_Calabria_5m_33N/DEM_Calabria_5m_33N.tif", "C:/Users/Desktop/geocoding/EM_Calabria_5m_33N/", "ras", "SIZE_OF_TILE", "TIFF", "NEAREST", "#", "1201 1201", "10", "PIXELS", "#","#","#", "#","#","-32767")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.