1

I'm new to ArcPy and am creating a script to automate some interpolation work.

I have multiple GA Layers outputted by an Empirical Bayesian Kriging interpolation (using arcpy.EmpiricalBayesianKriging_ga) which are in the in_memory workspace. I want to convert these GA layers to rasters for further manipulation.

Currently, I'm doing the following:

 for lyr in layers:
    print("Converting " + lyr + " to raster.")
    name = lyr + "_raster"

    arcpy.GALayerToRasters_ga(lyr, name, "PREDICTION")

Effectively reading each layer in from the in_memory workspace and converting them one at a time. This is fine for a couple layers, but it takes forever on larger collections of data (dozens or hundreds of layers).

Since the layers are independent from one another, this seems like a good application of multiprocessing to me. However, because the GA layers are all in the in_memory workspace, I'm under the impression that I will have to write each one to disk, read it back in, and then perform the GALayerToRasters_ga operation.

I want to do something like the below, but it predictably returns with "The layer does not exist."

def ga_layer_to_rasters_converter(layer):

    arcpy.env.workspace = "in_memory"
    arcpy.env.overwriteOutput = True

    print("Converting " + layer + " to raster.")
    name = layer + "_raster"

    # Names cannot be longer than 13 digits
    if (len(name) > 13):
        name = name[:13]

    arcpy.GALayerToRasters_ga(layer, name, "PREDICTION")

p = Pool(4)
p.map(ga_layer_to_rasters_converter, layers)
p.close()
p.join()

Do I have no choice but to write the GA layers to disk only to immediately read them back in?

I was hoping for a faster way to convert these GA layers to rasters.

  • Rasters in in_memory must conform to naming conventions, so no spaces, other characters or start with a number. You give no examples of what you are actually processing. Update your question with names of real layers and outputs you are attempting to process. – Hornbydd Jun 28 '18 at 10:19

Your Answer

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

Browse other questions tagged or ask your own question.