0

I have the code below

import arcpy, os
from arcpy.sa import *
arcpy.env.overwriteOutput = True
fc = r'E:\my saves\finaldata.dbf\finaldataD'
# Point feature class, needs to be in a file geodatabase (for the where clause to work)
output_folder = r'C:\GIS\data\testdata' # Where the rasters will be saved
date_field = 'date' # field holding the dates (date type, not string)
value_fields = ['CO', 'O3', 'NO2'] # field with the values to interpolate
all_dates = list({i[0] for i in arcpy.da.SearchCursor(fc, date_field)}) # List all unique dates
for date in all_dates:
 # Create a feature layer of each unique date
 where = "{0}=date '{1}'".format(arcpy.AddFieldDelimiters(datasource=fc, field=date_field),
 date.strftime('%Y-%m-%d'))
 arcpy.MakeFeatureLayer_management(in_features=fc, out_layer='lyr', where_clause=where)
 # For each field interpolate. This is untested since I dont have spatial analyst
 for fieldname in value_fields:
 outIDW = Idw(in_point_features='lyr', z_field=fieldname,
 cell_size=10) # , {power}, {search_radius}, {in_barrier_polyline_features})
 outIDW.save(os.path.join(output_folder, '{0}_{1}.tif'.format(fieldname, date.strftime('%Y%m%d'))))

but in the result I got runtime error

Traceback (most recent call last):
 File "C:/Users/USER/AppData/Roaming/JetBrains/PyCharm2020.1/scratches/arcgis.py", line 15, in <module>
 all_dates = list({i[0] for i in arcpy.da.SearchCursor(fc, date_field)}) # List all unique dates
RuntimeError: cannot open 'E:\my saves\finaldata.dbf\finaldataD'

can anyone tell me how to solve this problem?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked May 29, 2021 at 19:52
0

1 Answer 1

1

Shouldnt:

fc = r'E:\my saves\finaldata.dbf\finaldataD'

be:

fc = r'E:\my saves\finaldata.gdb\finaldataD'

answered May 30, 2021 at 6:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.