4

How do I use "exponential integral" function for raster calculation in ArcPy?

The equation that I want to apply in raster calculator is of the form EXPINT (r^2*S/(4*T*t)). Here, r, S, and t are constant parameters and I have raster file (say raster1 ) for T parameter.

I am a beginner.

import arcpy
import numpy as np
from scipy import special as sp
from arcpy import env
from arcpy.sa import *

raster1 = ("D:/raster1")
raster2 = ("D:/raster2")
raster3 = (raster1 * raster2 * 30 * 4 * np.pi)/-sp.expi(- (0.20 ** 2 * 0.0001/(4 * raster1 * 30)))
2

Short Answer: ESRI's Spatial Analysis Map Algebra contains a fixed set of operators which can manipulate rasters. Your desired EXPINT() function is not among them.

Longer Answer: Since you want to calculate this value for every cell in a new raster based on constants and the value of a corresponding cell in an existing raster, a new feature called the Raster Cell Iterator (RCI) will (maybe) be able to help solve this problem.

Essentially, it is an iterator to access one cell at a time for every row/column in a given raster; read about it here.

You can see python code to iterate and compute individual cells in this example blog post.

What you will be doing is something like this:

import arcpy
import numpy as np
from scipy import special as sp
from arcpy import env
from arcpy.sa import *

for [r,c] in raster3:
    raster3[r,c] =  (raster1[r,c] * raster2[r,c] * 30 * 4 * np.pi)/-sp.expi(- (0.20 ** 2 * 0.0001/(4 * raster1[r,c] * 30)))

raster3.save()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.