-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount-attachments.py
42 lines (36 loc) · 1.34 KB
/
count-attachments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -----
from arcgis.gis import GIS
portalId_HostedFeatureServiceItem = '904467ee2fbb45f1ac816dd5ff3768ed'
gis = GIS('home')
print(gis)
# -----
hfl_item = gis.content.get(portalId_HostedFeatureServiceItem)
hfl_layer = hfl_item.layers[0] #just the first feature layer in the feature service
hfl_featureset = hfl_layer.query()
hfl_features = hfl_featureset.features
hfl_attachments = hfl_layer.attachments
print(hfl_item.url)
# -----
countRecords = len(hfl_features)
print("Record count: " + str(countRecords))
# -----
countAttachments = hfl_attachments.count(where='1=1')
print("Attachments count: " + str(countAttachments))
# ----- below is no longer needed now that i've got the "count()" method working
#countFeatures = 0
#countAttachments = 0
#for feat in hfl_features:
# countFeatures+=1
# attribs = feat.attributes
# oid = attribs.get('OBJECTID')
# attach = hfl_attachments.get_list(oid)
# numAttachments = len(attach)
# countAttachments = countAttachments + numAttachments
# strToPrint = 'record: ' + str(countFeatures) + ', OID: ' + str(oid) + \
# ', num attachments: ' + str(numAttachments)
# print(strToPrint)
#print('------------------------------------------')
#strTally = 'Total Feature Records: ' + str(countFeatures) + \
# ', Total Attachments: ' + str(countAttachments)
#print(strTally)
# -----