How do I query all features that do not have a attachment on ArcOnline?

1261
3
10-02-2019 08:20 AM
PatrickGrogan-Myers
New Contributor

I am currently working on a housing survey for the city. I want to pull all features that do not have an attachment to make sure that we get a picture of each house in the city. Is this possible?

Tags (1)
0 Kudos
3 Replies
alex_friant
Occasional Contributor II

I'd say it's possible with some python for the arcgis api. https://developers.arcgis.com/python/guide/using-attachments-with-feature-layers/

Rough sketch of how to:

  • Loop through all records in your hosted feature layer
  • Query each record to see if it has an attachment
  • Build an array logging all records which have zero attachments
  • Put that array into a target table of your choice so you can use in your workflow
Peter_Klingman
Esri Regular Contributor

Hi Patrick Grogan-Myers‌,

Using a definition expression that queries all the object id's with Query Attachments can return all the features that have attachments: Query Attachments (Feature Service/Layer)—ArcGIS REST API: Services Directory | ArcGIS for Developer.... Once you have those object id's you could feasibly list them and then query the layer for object id's not equal to those in the list. I have not tried this second part myself so I'm not 100% sure if it would work or not. 

Another option is to use Arcade to filter the features without attachments in a Web Map. This is explained on this GeoNet blog. See Part 1: Calculate the attachment ID - except the filter in step 4 would be CountAttachments equals 0. 

I'm thinking Arcade might be the better option here as it will allow you to see the location of houses without pictures right off the bat. Hope this helps!

-Peter

ChristopherMcClain
Occasional Contributor II

check this article out I found it very helpful for doing a very similar task.

 Visualize your attachments in ArcGIS Online with Arcade