loop through geostatistical layers in a folder

5014
8
Jump to solution
03-13-2015 09:25 PM
SuiTao
by
New Contributor II

Hello everyone,

I'm trying to write a python script to loop through geostatistical layers in a folder (a snapshot is attached below), then loop through another folder which contains a  point shapefile (a snapshot attached as well), find the match between the two  based on names (e.g., 1a1a0.lyr vs 1a1a0 in the 'dateid' field), and last, use a 'GA layer to point' to the matching points. So how can I accomplish this task? More specifically, how do I create a nested loop to match the layers with the points of one shapefile?

Many thanks,

Sui

These are a sample of layers

layers.jpg

This is the attribute table of points

points.jpg

0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

I'm not sure of an arcpy method to list lyrs, but you can do so with os.listdir(). Then, loop through the list, creating a where clause. Finally, Select tool using where clause to extract matching points.

View solution in original post

8 Replies
DarrenWiens2
MVP Honored Contributor

I'm not sure of an arcpy method to list lyrs, but you can do so with os.listdir(). Then, loop through the list, creating a where clause. Finally, Select tool using where clause to extract matching points.

SteveLynch
Esri Regular Contributor

In 10.2 we introduced a Python class GeostatisticalDatasets which will make it easier for you to match up the datasets.

ga_layer = r"c:\temp\kriging.lyr"
geo_datasets = arcpy.GeostatisticalDatasets(ga_layer)
print geo_datasets
>>dataset1='c:\temp\myfc.shp' dataset1Field='ELEVATION'

-Steve

XIANWANG
New Contributor

Hi, I want to know if Python class GeostatisticalDatasets​also existed in version 10.

Thank you!

0 Kudos
EricKrause
Esri Regular Contributor

It was first released in ArcGIS 10.2.  It is not in 10 or 10.1.

XIANWANG
New Contributor

Hello, here, we can do the loop? I mean I can chang dataset1 every time, then do the interpolation for the different dataset1?

  1. ga_layer = r"c:\temp\kriging.lyr" 
  2. geo_datasets = arcpy.GeostatisticalDatasets(ga_layer) 
  3. print geo_datasets 
  4. >>dataset1='c:\temp\myfc.shp' dataset1 Field='ELEVATION'
0 Kudos
EricKrause
Esri Regular Contributor

If you are using ArcGIS 10 or 10.1, you will need to pass the datasets using strings.  The GeostatisticalDatasets object will not work because it does not exist in 10 or 10.1.

For an example of the syntax of the string, see the code samples at the bottom of the ArcGIS 10 help topic:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Create_Geostatistical_Layer/0030000000...

0 Kudos
XIANWANG
New Contributor

Thanks a lot. I download Version 10.3 and I solved the problem.

0 Kudos
SuiTao
by
New Contributor II

Thanks guys for the reply.

Darren's answer is closer to what I want to achieve.

Cheers,

Sui

0 Kudos