HI!
I am trying to do "summarize within" with a multiple years of points data with a polygon. I need to summarize some columns in the table of the points within boundaries of the polygon. Since I have many point data files, I would like to use the "for" loop in Python notebook.
The problem is ... I can successfully do the process when I defined the "outFeatureClass" as one file. But when I try to make the "outFeatureClass" as the combination of path and the name (for multiple file), the results become quite strange.
The first code works, and the second code does not work.
1) the first code
arcpy.env.workspace = 'D:\WORK\PROJECT\COVID_19_4\GIS\CVD_STORE_INDVD_2.gdb'
polys = 'D:\WORK\PROJECT\COVID_19_4\GIS\CVD_STORE_INDVD.gdb\TBGIS_TRDAR_RELM'
fcs = arcpy.ListFeatureClasses("seo_biz_mstr_open*", "Point")
for fc in fcs:
outFeatureClass = 'D:\WORK\PROJECT\COVID_19_4\GIS\CVD_STORE_INDVD.gdb\seo_biz_mstr_open_201903_test_out_out'
keepAll = 'KEEP_ALL'
sumFields = [["STR_TOT","SUM"]]
addShapeSum = 'ADD_SHAPE_SUM'
addMinMaj = 'NO_MIN_MAJ'
addPercents = 'NO_PERCENT'
arcpy.analysis.SummarizeWithin(polys, fc, outFeatureClass, keepAll,
sumFields, addShapeSum, '', '',
addMinMaj, addPercents)

2) the second code
arcpy.env.overwriteOutput=True
arcpy.env.workspace = 'D:\WORK\PROJECT\COVID_19_4\GIS\CVD_STORE_INDVD_2.gdb'
polys = 'D:\WORK\PROJECT\COVID_19_4\GIS\CVD_STORE_INDVD.gdb\TBGIS_TRDAR_RELM'
fcs = arcpy.ListFeatureClasses("seo_biz_mstr_open*", "Point")
for fc in fcs:
outFeatureClass = os.path.join(r"D:\WORK\PROJECT\COVID_19_4\GIS\CVD_STORE_INDVD.gdb", fc)
keepAll = 'KEEP_ALL'
sumFields = [["STR_TOT","SUM"]]
addShapeSum = 'ADD_SHAPE_SUM'
addMinMaj = 'NO_MIN_MAJ'
addPercents = 'NO_PERCENT'
arcpy.analysis.SummarizeWithin(polys, fc, outFeatureClass, keepAll,
sumFields, addShapeSum, '', '',
addMinMaj, addPercents)
I cannot see any difference between the two code, rather than the way of defining the outfeatureclass, but the outcome seems quite different (the first one is correct).
Your advice would be very much appreciated.
The data is quite large, so I cannot upload, but I can provide via email if requested.