Please help: Python code that runs smoothly in ArcMap gets very slow in ArcGIS Pro

266
7
08-16-2020 10:37 PM
JoseIgnacio
New Contributor
Hello community,
I have a python script which runs smoothly in ArcMap, however, when I try to run it in ArcGIS Pro (2.5.1 version) it slows down greatly.  I have run the code step by step and for some reason the tasks take considerably longer in Pro.  The code basically performs mathematical operations (e.g. multiple multiplication, Ln) over satellite images (rasters) and other calculations such as NDVI. I've tried using in-memory workspace, and managing the rasters in memory. I try to avoid that the rasters get saved on disk, but it still does not speed up the performance.  For example:
Zom = Raster(Exp ( -5.5 + 5.8 * NDVI ),  r"memory\Zom")
canopy = Raster(Zom / 0.136, r"memory\canopy")
But this code still runs very slow in Pro.
I will appreciate any clue about this issue. Thank you in advance for sharing any experience or feedback
0 Kudos
7 Replies
DanPatterson
MVP Honored Contributor

ArcGIS Pro 2.6 system requirements—ArcGIS Pro | Documentation 

Did you run the link to check your computer's ability to run ArcGIS Pro?  (You can check older versions of Pro as well)

"Recommended" would be considered the minimum.  The amount by which your computer exceeds this would be important.  Ram and GPU are important.

Also, clear Pro's 'cache' from the project backstage.


... sort of retired...
0 Kudos
JoseIgnacio
New Contributor

Thanks for your reply...  Yes... the computer meets all the requirements...  and I still have the same issue... any other ideas?... 

Clearing the Pro's 'cache' from the project backstage helped just a bit with the execution time, and it is still very slow compared with the ArcGIS Map performance

Thanks

0 Kudos
DanPatterson
MVP Honored Contributor

Jose Ignacio

It was marked as Assumed Answered, so I thought you were done with the issue.

You also don't indicate how "slow" the operation takes.  Anything more than a minute is related to your system and comparing to arcmap doesn't help.  Pro 2.6 is quite speedy, so that might be a suggestion then.

As a final note, I normally do such simple calculations in numpy (using RasterToNumPyArray) since it is blazingly fast and return the resultant to arcpy using NumPyArrayToRaster.  You can account for nodata values quite simply


... sort of retired...
0 Kudos
JoseIgnacio
New Contributor

Thank you Dan for your quick help... I marked it as answered by mistake. 

My python script has approximately 271 lines of codes. Many operations over raster are computed really fast like 1-2 minutes. 

However, other parts are very slow taking like 1 hour long to execute only 4 lines of code, for example:

t26 = time.time()
U = Raster(( 0.41 * var) / ( Ln (( Z_Blend - Dis_Ht ) / Zom ) - var1 + var2 ), r"memory\Ustar_2")
ReStar_2 = Raster(0.009 * U / var3, r"memory\ReStar_2")
Ct_star_2 =  Raster(( 0.71 ** ( - 2 / 3 )) *  ( ReStar_2 ** -0.5 ), r"memory\Ct_star_2")
term2_2 = Raster(Con ( Zom == 0, 0, (( 2 * Conopy_cov * fs * 0.41 * U_Uh * ( Zom / Ht_Canopy )) / Ct_star_2 )), r"memory\term2_2")
print("execution time: ", round((time.time()-t26)/60, 2)) #

All the variables are raster. Maybe, are the conditionals (Con) time consuming?

Thank you

0 Kudos
JoseIgnacio
New Contributor

Btw... I am gonna try RasterToNumPyArray

Thanks!!

0 Kudos
DanPatterson
MVP Honored Contributor

From my previous persona, I have a number of blogs relating to raster/numpy stuff

https://community.esri.com/blogs/dan_patterson/tags#/?tags=rastertonumpyarray 


... sort of retired...
JoseIgnacio
New Contributor

Thank you Dan!... I have still problems with my code... I was not able to run the RasterToNumPyArray option...   I am posting a new question with more detailed explanation.. in case you wanna help!.. thanks!

0 Kudos