Select to view content in your preferred language

Determining "is hosted feature service" vs "View Layer" using the python API for ArcGIS

167
3
Jump to solution
01-25-2025 10:32 AM
rob_hewy
Frequent Contributor

When you run an item report there is a column called "is hosted feature service".

I want to get the same info but using the ArcGIS Python API.

Any ideas?

I am also looking for a property that might inform me that a a Feature layer is a View layer versus the hosted feature service supporting the view layer.

I would also love the view layer to be a filter in the content area too.

All the best,

Rob

 

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

There appears to be an identifier in the Item property typeKeywords - 'View Service'

from arcgis.gis import GIS
gis = GIS("home")

#replace with your layer id
feature_id='73fdbf4gxxxxxxxxxxxx'

item = gis.content.get(feature_id)  

#item property 'typeKeywords' produces a list which 
#should have a 'View Service' element listed if so
print(item.typeKeywords)

#if it is a view service - print typeKewords properties
if "View Service" in str(item.typeKeywords):
  print(str(item.typeKeywords))

 

View solution in original post

3 Replies
DavidPike
MVP Frequent Contributor

There appears to be an identifier in the Item property typeKeywords - 'View Service'

from arcgis.gis import GIS
gis = GIS("home")

#replace with your layer id
feature_id='73fdbf4gxxxxxxxxxxxx'

item = gis.content.get(feature_id)  

#item property 'typeKeywords' produces a list which 
#should have a 'View Service' element listed if so
print(item.typeKeywords)

#if it is a view service - print typeKewords properties
if "View Service" in str(item.typeKeywords):
  print(str(item.typeKeywords))

 

rob_hewy
Frequent Contributor

Just wanted to add a little more for others:

Solving for hosted could be done via the typeKeywords too (see the last item in the list):

['ArcGIS Server', 'Data', 'Feature Access', 'Feature Service', 'Metadata', 'Multilayer', 'Service', 'Hosted Service']

 The feature layers I am currently investigating do not say 'View Service', instead they say 'ArcGIS API for JavaScript'

 ['ArcGIS API for JavaScript', 'ArcGIS Server', 'Data', 'Feature Access', 'Feature Service', 'Service', 'Singlelayer']

Both of the above eventually make it back to the same hosted service in our portal.

Although, I thought the SingleLayer might be a view layer this may not be the case; the later may have been made via Content => New Item => URL. 

 

 

 

0 Kudos
DavidPike
MVP Frequent Contributor

Ah that's useful info.  I'll also add that the view I checked returns both 'Hosted Service' and 'View Service' in the list - so may need additional checks such as if 'Hosted Service' in list and 'View Service' not in list etc. Could be other gotchas to be aware of also.

0 Kudos