Select to view content in your preferred language

Access geostatistical layer created using ArcPy

779
5
Jump to solution
10-02-2024 01:34 AM
GarethNash
Emerging Contributor

Hi, 

I have used ArcPy to carry out EBK 3D successfully - code provided below.

During this process a geostatistical layer is created; when run from the GIS Pro UI this layer is loaded to the current map and is accessible for future use. 

I'm finding that I'm unable to find the geostatistical layer created during EBK3D using ArcPy and once the kernel has restarted (using a Jupyter notebook) the GA layer is no longer available for use in further processing (e.g., export to NetCDF voxel). 

Is this the expected behaviour? I'm planning to run EBK3D on a number of input layers and write them to the same NetCDF voxel model. If the GA layers created using ArcPy are 'lost' once the kernel restarts then I will have to do it all in one go which isnt an issue but would be helpful to know. 

 

 

trial_fcs = [output_gdb+"\\GEN_selected_features", 
             output_gdb+"\\NTV_selected_features", 
             output_gdb+"\\STV_selected_features"]

ebk3d_results = {}  # Create a dictionary to store ebk3d results

for trial in trial_fcs:

    filename = os.path.basename(trial)
    last_part = filename.split('.')[0]  # Remove extension if present

    # Use a unique identifier based on the last_part
    unique_identifier = f"ebk3d_{last_part}"

    print(f"Starting Empirical Bayesian Kriging 3D (EBK3D) on {last_part}...")
    ebk3d_results[unique_identifier] = arcpy.ga.EmpiricalBayesianKriging3D(
                                                in_features=trial,
                                                elevation_field="depth",
                                                value_field="value",
                                                out_ga_layer=f"C:\\Users\\<x.y>\\Documents\\ArcGIS\\Projects\\RVO\\kriging_test\\EBK3D_{last_part}.lyr",
                                                elevation_units="METER",
                                                measurement_error_field=None,
                                                semivariogram_model_type="EXPONENTIAL",
                                                transformation_type="LOGEMPIRICAL",
                                                subset_size=100,
                                                overlap_factor=1,
                                                number_simulations=100,
                                                trend_removal="NONE",
                                                elev_inflation_factor=None,
                                                search_neighborhood="NBRTYPE=Standard3D RADIUS=nan NBR_MAX=2 NBR_MIN=1 SECTOR_TYPE=TWELVE_SECTORS",
                                                output_elevation=None,
                                                output_type="PREDICTION",
                                                quantile_value=0.5,
                                                threshold_type="EXCEED",
                                                probability_threshold=None
                                                )
    print(f"EBK3D process completed successfully for {last_part}...")

 

 

  

0 Kudos
1 Solution

Accepted Solutions
EricKrause
Esri Regular Contributor

Hi @GarethNash,

Geostatistical layers are in-memory layers and not stored on disk, so they will be gone if you restart the kernel.  However, they can be saved as layer files with the Save To Layer File geoprocessing tool, so they can be exported later.

-Eric

View solution in original post

5 Replies
DanPatterson
MVP Esteemed Contributor

The output is  layer and not a file of a particular type and its storage is different

What is a geostatistical layer?—ArcGIS Pro | Documentation

This link 

Geostatistical layers in 3D—ArcGIS Pro | Documentation

indicates that layers can be converted to your noted format amongst others for further analysis


... sort of retired...
0 Kudos
GarethNash
Emerging Contributor

Thanks Dan. 

I understand how the layers are stored when created from within GIS Pro and added to a map (i.e., created via the geoprocessing window, python window, embedded notebook, model builder etc.).

I'm looking to confirm that in my case (Jupyter notebook in VS Code) once the kernel has been reset the GA layer is no longer accessible? 

I ran a number of kriging trials and cross validation but did not export the GA layers to voxel in the same process thinking I could come back and do it later however I'm now unable to find/use the GA layer. 

0 Kudos
DanPatterson
MVP Esteemed Contributor

The only other reference in arcpy is

GeostatisticalDatasets—ArcGIS Pro | Documentation

which takes the original source for the geostatistical layer as input


... sort of retired...
0 Kudos
EricKrause
Esri Regular Contributor

Hi @GarethNash,

Geostatistical layers are in-memory layers and not stored on disk, so they will be gone if you restart the kernel.  However, they can be saved as layer files with the Save To Layer File geoprocessing tool, so they can be exported later.

-Eric

GarethNash
Emerging Contributor

Thanks Eric - thats what I thought but didnt know about the Save to Layer File tool so will build that into my process. 

0 Kudos