Select to view content in your preferred language

ArcPy SaveToLayerFile Fails – ArcGIS Pro 3.5.2 / Python 3.11.11

603
0
2 weeks ago
JohnHernandez
Emerging Contributor

I'm running a Python script on a local server that functions as a web service. The script receives a text file containing a list of parcel identifiers and uses ArcPy (Python 3.11.11) within ArcGIS Pro 3.5.2 to generate geospatial images for each parcel.

The images are derived from raster datasets (Raster Dataset and Mosaic Dataset) stored in a geospatial database. The workflow includes:

  1. Reading parcel IDs from a text file.
  2. Filtering parcel and image datasets based on each ID.
  3. Converting filtered data into layers.
  4. Saving layers as .lyrx files using arcpy.SaveToLayerFile.
  5. Adding layers to an ArcGIS Pro project.
  6. Exporting images as .jpg.
  7. Compressing the images into a .zip file.

Issue:

The script consistently fails during the SaveToLayerFile step after generating approximately 47 images. The error message is:

ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug and refer to the error help for potential solutions or workarounds.

Failed to execute (SaveToLayerFile).

This generic error doesn’t provide much insight. I’ve tried:

  • Running the script in batches (500, 100, 50, 25).
  • Adding timeouts between iterations.

The maximum output achieved is ~47 images (24 parcels × 3 image datasets), which suggests a possible issue with resource accumulation, memory handling, or internal ArcPy limitations.

Environment Details:

  • ArcGIS Pro: 3.5.2
  • Python: 3.11.11 (ArcPy)
  • Execution Environment: Local server (not virtualized or containerized)
  • Memory Usage: ~25% during execution
  • Dataset Access: No restrictions from the script, but no admin access to inspect internal dataset configurations
  • Data Behavior: No specific parcel or dataset pattern identified that triggers the error

Looking for:

  • Has anyone encountered similar behavior with SaveToLayerFile?
  • Are there known limitations or memory issues with ArcPy in this context?
  • Any suggestions for debugging or optimizing this workflow?
Tags (3)
0 Kudos
0 Replies