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
This is the attribute table of points
Solved! Go to Solution.
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.
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.
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
Hi, I want to know if Python class GeostatisticalDatasetsalso existed in version 10.
Thank you!
It was first released in ArcGIS 10.2. It is not in 10 or 10.1.
Hello, here, we can do the loop? I mean I can chang dataset1 every time, then do the interpolation for the different dataset1?
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:
Thanks a lot. I download Version 10.3 and I solved the problem.
Thanks guys for the reply.
Darren's answer is closer to what I want to achieve.
Cheers,
Sui