0

I have a raster representing the elevation of an entire city (1-meter resolution LiDAR DSM) and I would like to calculate the average height of the features in the city for 200mx200m squares. I am using QGIS.

How can I do that?

Vince
  • 20,017
  • 15
  • 45
  • 64
anna
  • 21
  • 2
  • Welcome to gis.stackexchange, Anna! One workaround I can think of is to convert the raster tiles to polygons given that the number of the tiles is not that large. Then, you may use zonal statistics to estimate the average elevation for each raster tile. You need to repeat this process as many times as the number of the raster tiles. Does it help or are you looking for sth else? – Ilias Machairas Oct 18 '21 at 21:00
  • Many thanks for your answer Ilias! Actually, my raster file is very large (medium city size). And one complication is that the squares in which I calculate the average height are overlapping (I need to calculate the average and then move the square a few meters away and do the same, for the entire city). So I guess an algorithm would be better for that, maybe using GDAL? – anna Oct 19 '21 at 16:06
  • You can have a look at this question https://gis.stackexchange.com/questions/187877/how-to-polygonize-raster-to-shapely-polygons in order to create a polygon from a raster. If you want to automate this step for all raster images, follow the next code. Firstly, keep all of them in the same folder. Comma , represents a new line. import os, cwd = os.getcwd(), data_path = os.path.join(cwd, 'Folder_1\subfolder'), for i in os.listdir(data_path): path_file= os.path.join(data_path, i). Folder_1 and subfolder are random names, They will change based on where you saved your images. – Ilias Machairas Oct 19 '21 at 19:28

0 Answers0