Select to view content in your preferred language

Notebook in ArcGIS Pro running very slowly

552
3
10-01-2024 10:37 AM
jacob_ekn
Occasional Contributor

Wondering if anyone has anything I could try for speeding up the run time for notebooks in ArcGIS Pro, I have a tool that throws some unexplained error when ran as a script tool (Summarize Within - ModuleNotFoundError: No module named 'common') so I had to convert it to a notebook instead. Before the unexplained error came around, the script tool averaged less than 10 minutes to run to completion but the same code as a notebook takes over an hour to complete.

3 Replies
DuncanHornby
MVP Notable Contributor

You need to share your code as no one has a chance in answering this question. For a start the error is pointing to a module called common, did you create that, where is it?

Also code that was running fine one day but now slowly the next strongly suggests its not the code that's changed its your input dataset. You need to provide detail on that too.

0 Kudos
jacob_ekn
Occasional Contributor

Hi @DuncanHornby, here's the function where I'm getting the error:

def sp_project(in_points, out_proj):
    state_plane = r"C:\LidarToTopo\temp_data.gdb\CA_State_Plane_Zones"

    # Perform summarize within tool to find number of lidar points in each state plane
    sum_within = r"C:\LidarToTopo\temp_data.gdb\sum_within"
    arcpy.analysis.SummarizeWithin(in_polygons=state_plane, in_sum_features=in_points, out_feature_class=sum_within)

    # Get state plane zone with highest number of lidar points
    fields = ['ZONE', 'Point_Count']
    allvalues = [row for row in arcpy.da.SearchCursor(sum_within, fields)]
    proj_zone = max(allvalues, key=lambda x: x[1])[0]
    arcpy.management.Delete(sum_within)

    # Dictionary for returning full state plane projection name
    coor_sys = {
        "CA_1": "NAD 1983 StatePlane California I FIPS 0401 (US Feet)",
        "CA_2": "NAD 1983 StatePlane California II FIPS 0402 (US Feet)",
        "CA_3": "NAD 1983 StatePlane California III FIPS 0403 (US Feet)",
        "CA_4": "NAD 1983 StatePlane California IV FIPS 0404 (US Feet)",
        "CA_5": "NAD 1983 StatePlane California V FIPS 0405 (US Feet)",
        "CA_6": "NAD 1983 StatePlane California VI FIPS 0406 (US Feet)"
    }

    # Project lidar points to state plane zone with most points within it
    out_coor_sys = arcpy.SpatialReference(coor_sys[proj_zone])
    arcpy.management.Project(in_dataset=in_points, out_dataset=out_proj, out_coor_system=out_coor_sys)
    return out_coor_sys

The error is coming from the SummarizeWithin tool. It seems that another person was getting an identical error, also with the SummarizeWithin tool, a few months ago and it looks like it also was never resolved. Summarize within -- ModuleNotFoundError: No module named 'common' for reference. I didn't create any module named 'common.'

I used the same dataset for testing. So the exact same script with the exact same data input worked sometimes, didn't work others. Also, just to clarify, the original script tool that I made either runs very quickly the few times that it works, and otherwise throws the ModuleNotFoundError. The notebook version always runs successfully, but takes about an hour and a half to run.

0 Kudos
DuncanHornby
MVP Notable Contributor

The summarize within tool is one of those python script tools created by esri. A deep dive into that code suggest common is a folder it imports from. Not sure why it would suddenly error and why it would suddenly take hours to process.

0 Kudos