Re: [Qgis-user] Raster calculator script failing for multiple rasters

2016-09-14 Thread Nicolas Cadieux
Hi what kind of error are you getting?  Is Qgis  just crashing? Do you get an 
error message?  Does the script work with smaller files?  

Nicolas

Envoyé de mon iPad

> Le 14 sept. 2016 à 02:05, R HG [via OSGeo.org] 
>  a écrit :
> 
> Thanks Nicolas for your reply.
> 
> It does seem to be a memory problem, although it doesnt show the typical 
> "Memory Error". Without the script I could do that operation with the same 
> rasters. It involves four files and it is basically (a-b)*(c-d). 
> 
> GDAL also failed to load all files at once, so I finally splited the 
> operation in 3. (a-b) then (c-d) and finaly the multiplication of the 
> outputs. Its much more time consuming but it works.
> 
> I still dont understand why using the tool directly from the UI it wrks and 
> it doesnt from the script. Will write back if I find the correct way.
> 
>> 
>> 
>> Hi,
>> 
>> I have never use the Qgis raster calculator via Python so I can't help 
>> there. What is the problem? Does Qgis crash?  If so, the rasters may be to 
>> big for the memory.   You mentioned the rasters were very big and that may 
>> be the problem.  I recommend you test the calculation with smaller rasters.  
>> I think they are working for a solution for the big raster math.
>> 
>> Saga and gdal calculator may help.  Saga will probably try to load 
>> everything in memory an may crash.  Gdal is made to calculate very big 
>> rasters but layers must be in the same CRS and have the same pixel posting 
>> and extent.  You can use it direction in the Osgeo command prompt or via 
>> processing.
>> 
>> Nicolas
>> 
>> 
>> Envoyé de mon iPad
>> 
>> > Le 13 sept. 2016 à 05:42, ROMAN HG [via OSGeo.org] <> > onclick="_e(event, 'cvml', 
>> > 'ml-node+s1560n5285491...@n6.nabble.com')">ml-node+s1560n5285491h82@...>
>> >  a écrit :
>> >
>> > Hi,
>> >
>> > I'm trying to do raster calculations with big and multiple rasters. I am 
>> > new to python, but I managed to use the QgsRasterCalculator algorithm to 
>> > do the average of three rasters.
>> >
>> > The problem comes when I introduce a forth layer and try to do a more 
>> > complex equation:
>> >
>> > #calculating c4s ( [c1-c2]*[c0-c3] )
>> >
>> > #F1_30
>> > A=processing.getObjectFromUri(path + "/F1_30c1.tif")
>> > B=processing.getObjectFromUri(path + "/F1_c2.tif")
>> > C=processing.getObjectFromUri(path + "/F1_30c0.tif")
>> > D=processing.getObjectFromUri(path + "/F1_c3.tif")
>> >
>> > entries=[]
>> > rasA=QgsRasterCalculatorEntry()
>> > rasA.ref='A@1'
>> > rasA.raster=A
>> > rasA.bandNumber=1
>> > entries.append(rasA)
>> >
>> > rasB=QgsRasterCalculatorEntry()
>> > rasB.ref='B@1'
>> > rasB.raster=B
>> > rasB.bandNumber=1
>> > entries.append(rasB)
>> >
>> > rasC=QgsRasterCalculatorEntry()
>> > rasC.ref='C@1'
>> > rasC.raster=C
>> > rasC.bandNumber=1
>> > entries.append(rasC)
>> >
>> > rasD=QgsRasterCalculatorEntry()
>> > rasD.ref='D@1'
>> > rasD.raster=D
>> > rasD.bandNumber=1
>> > entries.append(rasD)
>> >
>> > F1_30c4=QgsRasterCalculator('(( A@1 - B@1 ) * ( C@1 - D@1 ))', path + 
>> > '/F1_30c4.tif', 'GTiff', base.extent(), base.width(), base.height(), 
>> > entries).processCalculation()
>> >
>> > I think that the problem is recognising the formula. I have tried it on 
>> > the console doing several changes and it doesnt work.
>> >
>> > Is it possible to do this operation with QgsRasterCalculator?? Or how can 
>> > I use the gdal_calc algorithm or the saga raster calculator??
>> >
>> >
>> > Thanks all
> 
> ___ 
> Qgis-user mailing list 
> [hidden email] 
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://osgeo-org.1560.x6.nabble.com/Raster-calculator-script-failing-for-multiple-rasters-tp5285491p5285719.html
> To start a new topic under Quantum GIS - User, email 
> ml-node+s1560n4125267...@n6.nabble.com 
> To unsubscribe from Quantum GIS - User, click here.
> NAML




--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Raster-calculator-script-failing-for-multiple-rasters-tp5285491p5285825.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Raster calculator script failing for multiple rasters

2016-09-13 Thread R HG
Thanks Nicolas for your reply.

It does seem to be a memory problem, although it doesnt show the typical
"Memory Error". Without the script I could do that operation with the same
rasters. It involves four files and it is basically (a-b)*(c-d).

GDAL also failed to load all files at once, so I finally splited the
operation in 3. (a-b) then (c-d) and finaly the multiplication of the
outputs. Its much more time consuming but it works.

I still dont understand why using the tool directly from the UI it wrks and
it doesnt from the script. Will write back if I find the correct way.


>
> Hi,
>
> I have never use the Qgis raster calculator via Python so I can't help
> there. What is the problem? Does Qgis crash?  If so, the rasters may be to
> big for the memory.   You mentioned the rasters were very big and that may
> be the problem.  I recommend you test the calculation with smaller
> rasters.  I think they are working for a solution for the big raster math.
>
> Saga and gdal calculator may help.  Saga will probably try to load
> everything in memory an may crash.  Gdal is made to calculate very big
> rasters but layers must be in the same CRS and have the same pixel posting
> and extent.  You can use it direction in the Osgeo command prompt or via
> processing.
>
> Nicolas
>
>
> Envoyé de mon iPad
>
> > Le 13 sept. 2016 à 05:42, ROMAN HG [via OSGeo.org] <
> ml-node+s1560n5285491...@n6.nabble.com > a écrit :
> >
> > Hi,
> >
> > I'm trying to do raster calculations with big and multiple rasters. I am
> new to python, but I managed to use the QgsRasterCalculator algorithm to do
> the average of three rasters.
> >
> > The problem comes when I introduce a forth layer and try to do a more
> complex equation:
> >
> > #calculating c4s ( [c1-c2]*[c0-c3] )
> >
> > #F1_30
> > A=processing.getObjectFromUri(path + "/F1_30c1.tif")
> > B=processing.getObjectFromUri(path + "/F1_c2.tif")
> > C=processing.getObjectFromUri(path + "/F1_30c0.tif")
> > D=processing.getObjectFromUri(path + "/F1_c3.tif")
> >
> > entries=[]
> > rasA=QgsRasterCalculatorEntry()
> > rasA.ref='A@1'
> > rasA.raster=A
> > rasA.bandNumber=1
> > entries.append(rasA)
> >
> > rasB=QgsRasterCalculatorEntry()
> > rasB.ref='B@1'
> > rasB.raster=B
> > rasB.bandNumber=1
> > entries.append(rasB)
> >
> > rasC=QgsRasterCalculatorEntry()
> > rasC.ref='C@1'
> > rasC.raster=C
> > rasC.bandNumber=1
> > entries.append(rasC)
> >
> > rasD=QgsRasterCalculatorEntry()
> > rasD.ref='D@1'
> > rasD.raster=D
> > rasD.bandNumber=1
> > entries.append(rasD)
> >
> > F1_30c4=QgsRasterCalculator('(( A@1 - B@1 ) * ( C@1 - D@1 ))', path +
> '/F1_30c4.tif', 'GTiff', base.extent(), base.width(), base.height(),
> entries).processCalculation()
> >
> > I think that the problem is recognising the formula. I have tried it on
> the console doing several changes and it doesnt work.
> >
> > Is it possible to do this operation with QgsRasterCalculator?? Or how
> can I use the gdal_calc algorithm or the saga raster calculator??
> >
> >
> > Thanks all
>
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Raster calculator script failing for multiple rasters

2016-09-13 Thread Nicolas Cadieux
Hi,

I have never use the Qgis raster calculator via Python so I can't help there. 
What is the problem? Does Qgis crash?  If so, the rasters may be to big for the 
memory.   You mentioned the rasters were very big and that may be the problem.  
I recommend you test the calculation with smaller rasters.  I think they are 
working for a solution for the big raster math.

Saga and gdal calculator may help.  Saga will probably try to load everything 
in memory an may crash.  Gdal is made to calculate very big rasters but layers 
must be in the same CRS and have the same pixel posting and extent.  You can 
use it direction in the Osgeo command prompt or via processing.

Nicolas


Envoyé de mon iPad

> Le 13 sept. 2016 à 05:42, ROMAN HG [via OSGeo.org] 
>  a écrit :
> 
> Hi,
> 
> I'm trying to do raster calculations with big and multiple rasters. I am new 
> to python, but I managed to use the QgsRasterCalculator algorithm to do the 
> average of three rasters.
> 
> The problem comes when I introduce a forth layer and try to do a more complex 
> equation:
> 
> #calculating c4s ( [c1-c2]*[c0-c3] )
> 
> #F1_30
> A=processing.getObjectFromUri(path + "/F1_30c1.tif")
> B=processing.getObjectFromUri(path + "/F1_c2.tif")
> C=processing.getObjectFromUri(path + "/F1_30c0.tif")
> D=processing.getObjectFromUri(path + "/F1_c3.tif")
> 
> entries=[]
> rasA=QgsRasterCalculatorEntry()
> rasA.ref='A@1'
> rasA.raster=A
> rasA.bandNumber=1
> entries.append(rasA)
> 
> rasB=QgsRasterCalculatorEntry()
> rasB.ref='B@1'
> rasB.raster=B
> rasB.bandNumber=1
> entries.append(rasB)
> 
> rasC=QgsRasterCalculatorEntry()
> rasC.ref='C@1'
> rasC.raster=C
> rasC.bandNumber=1
> entries.append(rasC)
> 
> rasD=QgsRasterCalculatorEntry()
> rasD.ref='D@1'
> rasD.raster=D
> rasD.bandNumber=1
> entries.append(rasD)
> 
> F1_30c4=QgsRasterCalculator('(( A@1 - B@1 ) * ( C@1 - D@1 ))', path + 
> '/F1_30c4.tif', 'GTiff', base.extent(), base.width(), base.height(), 
> entries).processCalculation()
> 
> I think that the problem is recognising the formula. I have tried it on the 
> console doing several changes and it doesnt work.
> 
> Is it possible to do this operation with QgsRasterCalculator?? Or how can I 
> use the gdal_calc algorithm or the saga raster calculator??
> 
> 
> Thanks all
> 
> ___ 
> Qgis-user mailing list 
> [hidden email] 
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://osgeo-org.1560.x6.nabble.com/Raster-calculator-script-failing-for-multiple-rasters-tp5285491.html
> To start a new topic under Quantum GIS - User, email 
> ml-node+s1560n4125267...@n6.nabble.com 
> To unsubscribe from Quantum GIS - User, click here.
> NAML




--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Raster-calculator-script-failing-for-multiple-rasters-tp5285491p5285530.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Raster calculator script failing for multiple rasters

2016-09-13 Thread R HG
Hi,

I'm trying to do raster calculations with big and multiple rasters. I am
new to python, but I managed to use the QgsRasterCalculator algorithm to do
the average of three rasters.

The problem comes when I introduce a forth layer and try to do a more
complex equation:

#calculating c4s ( [c1-c2]*[c0-c3] )

#F1_30
A=processing.getObjectFromUri(path + "/F1_30c1.tif")
B=processing.getObjectFromUri(path + "/F1_c2.tif")
C=processing.getObjectFromUri(path + "/F1_30c0.tif")
D=processing.getObjectFromUri(path + "/F1_c3.tif")

entries=[]
rasA=QgsRasterCalculatorEntry()
rasA.ref='A@1'
rasA.raster=A
rasA.bandNumber=1
entries.append(rasA)

rasB=QgsRasterCalculatorEntry()
rasB.ref='B@1'
rasB.raster=B
rasB.bandNumber=1
entries.append(rasB)

rasC=QgsRasterCalculatorEntry()
rasC.ref='C@1'
rasC.raster=C
rasC.bandNumber=1
entries.append(rasC)

rasD=QgsRasterCalculatorEntry()
rasD.ref='D@1'
rasD.raster=D
rasD.bandNumber=1
entries.append(rasD)

F1_30c4=QgsRasterCalculator('(( A@1 - B@1 ) * ( C@1 - D@1 ))', path +
'/F1_30c4.tif', 'GTiff', base.extent(), base.width(), base.height(),
entries).processCalculation()

I think that the problem is recognising the formula. I have tried it on the
console doing several changes and it doesnt work.

Is it possible to do this operation with QgsRasterCalculator?? Or how can I
use the gdal_calc algorithm or the saga raster calculator??


Thanks all
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user