Tuesday, 6 December 2016

CGIAR SRTM to xyz using GRASS GIS, with sampling



I have used CGIAR interface to select the tiles, like so: enter image description here


This resulted in a bunch of *.zip-files, and I have extracted them all into a directory. Next, I followed the instructions as https://grasswiki.osgeo.org/wiki/HOWTO_import_SRTM_elevation_data to turn everything into mosaic, like so:


 #create mosaik (optionally reproject on the fly with -t_srs)
gdalwarp *.tif srtm_mosaik.tif
# import
r.in.gdal input=srtm_mosaik output=srtm_mosaik location=srtm_mosaic_cgiar

Finally, I "connect" to the location srtm_mosaic_cgiar using grass-gui and export the tiles as xyz elevation data, using r.out.xyz (I use the File->Export... drop-down menu). Now my question is, since this operation appears to be hard on my laptop, and I can imagine the elevation data of Europe (as I have selected) is going to be huge, how to "restrict" r.out.xyz to sample (somehow) the exported data, or how to ascertain beforehand the size of the output?


My final goal is rather simple. I would like to have a file with x,y,z, where x,y refer to a "locus" somehwere in Europe, all the x,ys are mutually sufficiently apart (say, 300-500km), and z means the "elevation" of the respective point x,y. If there is a misconception on my part at this stage already, please feel free to correct me. I am new to GIS.



Answer




Since you have started with gdal, why no do the whole process using gdal utilities. I don't see the need for GRASS here (unless you need something more than what you have asked).


I would not create a new raster for all of Europe, rather use the Virtual Raster capability buildvrt, then the gdallocationinfo locationinfo should get you the elevation at each X-Y locations. i.e.: (after downloading and unzipping the tiles as you described)


gdalbuildvrt srtm.vft srtm*.tif
gdallocationinfo srtm.vft

That should do it. You could, of course, write a loop to extract Z values for a list of coord locations.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...