Instrução
Os anexos podem ser adicionados a uma camada no ArcGIS Pro, conforme descrito na seguinte documentação, ArcGIS Pro: adicionar ou remover anexos de arquivo, antes de publicar no ArcGIS Online ou Portal for ArcGIS. Quando uma camada contém vários anexos, pode ser tedioso calcular manualmente o tamanho total dos anexos. Além disso, o tamanho total pode variar considerando os diferentes tamanhos quando em disco, durante a publicação e a conversão de bytes em kilobytes. Este artigo fornece as etapas para utilizar o ArcGIS API for Python para calcular o tamanho total em um script Python independente ou ArcGIS Notebooks.
import arcgis from arcgis import GIS import pandas as pd
#For ArcGIS Online
gis = GIS('https://arcgis.com', 'username', 'password')
print("Connected")
#For Portal for ArcGIS
gis = GIS('https://<machine>.<domain>/<web adaptor name>', 'username', 'password', verify_cert=False)
print("Connected")
item = '<item_ID>' layer = gis.content.get(item) ids = layer.layers[0] fs = ids.query(where="1=1") oids = [f.attributes["OBJECTID"] for f in fs.features]
Note: Edit the index value in 'ids = item.layers[0]' based on the layers that hold the attachments. For example, to calculate the total attachment size in the second layer, replace 0 with 1 in the code.
attached = [ids.attachments.get_list(oid=oid) for oid in oids] print(attached)
print("Total size: " + str(ids.attachments.search(as_df=True)['SIZE'].sum()))
#If additional word is unnecessary, the following line can be used:
print(ids.attachments.search(as_df=True)['SIZE'].sum())
Veja a seguir um script de exemplo funcional e o console de resultados. O tamanho do arquivo calculado está em bytes.
import arcgis
from arcgis import GIS
import pandas as pd
gis = GIS('https://arcgis.com', 'user1', 'password1!')
print("Connected")
item = '80d00e2301844ou2435p9284fu87bf'
layer = gis.content.get(item)
ids = layer.layers[0]
fs = ids.query(where="1=1")
oids = [f.attributes["OBJECTID"] for f in fs.features]
attached = [ids.attachments.get_list(oid=oid) for oid in oids]
print (attached)
print("Total size: " + str(ids.attachments.search(as_df=True)['SIZE'].sum()))

ID do Artigo: 000031782
Obtenha ajuda de especialistas do ArcGIS
Comece a conversar agora