November 2018
Beginner to intermediate
272 pages
5h 36m
English
Loading raster data is very similar to loading vector data, and this is done using the addRasterLayer() command, as in the following example:
r_layer = iface.addRasterLayer('D:/QGIS_3_4/qgis_sample_data/raster/SR_50M_alaska_nad.tif','Hillshade')
To show the name of the raster, use the following:
r_layer.name()
The output is as follows:
Hillshade
To get the raster layer's size in pixels, we can use the width() and height() functions, as follows:
r_layer.width(), r_layer.height()
The output is as follows:
(1754, 1394)
If we want to know more about the raster values, we use the layer's data provider object. This provides access to the raster band statistics. To get the maximum value of the raster, ...
Read now
Unlock full access