Raster Manipulation in the QGIS Python Console

2 messages Options
Embed this post
Permalink
Agustin Lobo

Raster Manipulation in the QGIS Python Console

Reply Threaded More More options
Print post
Permalink
According to
http://www.maths.lancs.ac.uk/~rowlings/Qgis/Plugins/Documentation/rasterlang/python.html
I've done:

 >>> layer1 = iface.mapCanvas().layer(0)
 >>> layer1.name()

but get no answer, I was expecting getting the layer name, as indicated
in the web page
"This should show the names of your raster layers"

Nevertheles, computing works because I've done:
 >>> from rasterlang.layers import layerAsArray
 >>> a1 = layerAsArray(layer1)
 >>> a1.shape
 >>> rsum = a1 + a1
 >>> from rasterlang.layers import writeGeoTiff
 >>> e = layer1.extent()
 >>> extent = [e.xMinimum(),e.yMinimum(),e.xMaximum(),e.yMaximum()]
 >>> writeGeoTiff(rsum, extent,
"/media/Transcend/Anyella/calib20090730/rsum.tiff")

and I do get a correct rsum.tiff file that I can display in qgis.

Why am I not getting any answer from the console? a1.shape does not
return anything either

Thanks!

Agus
_______________________________________________
Qgis-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-user
Barry Rowlingson

Re: Raster Manipulation in the QGIS Python Console

Reply Threaded More More options
Print post
Permalink
On Tue, Oct 27, 2009 at 12:26 PM, Agustin Lobo <[hidden email]> wrote:

> According to
> http://www.maths.lancs.ac.uk/~rowlings/Qgis/Plugins/Documentation/rasterlang/python.html
> I've done:
>
>>>> layer1 = iface.mapCanvas().layer(0)
>>>> layer1.name()
>
> but get no answer, I was expecting getting the layer name, as indicated in
> the web page
> "This should show the names of your raster layers"
>
> Nevertheles, computing works because I've done:
>>>> from rasterlang.layers import layerAsArray
>>>> a1 = layerAsArray(layer1)
>>>> a1.shape
>>>> rsum = a1 + a1
>>>> from rasterlang.layers import writeGeoTiff
>>>> e = layer1.extent()
>>>> extent = [e.xMinimum(),e.yMinimum(),e.xMaximum(),e.yMaximum()]
>>>> writeGeoTiff(rsum, extent,
>>>> "/media/Transcend/Anyella/calib20090730/rsum.tiff")
>
> and I do get a correct rsum.tiff file that I can display in qgis.
>
> Why am I not getting any answer from the console? a1.shape does not return
> anything either

 The latest python console requires you to 'print' everything you want
to see. So:

print layer1.name()

 Nah, I don't like it either! I have written my own python console
plugin but it seemed to crash things quite a lot...

Barry
_______________________________________________
Qgis-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-user