|
POST
|
Hello community (cc @David_McRitchie), I've encountered an issue whereby when deleting unused fields from a hosted feature layer, some of the associated views are becoming corrupted. After some discussions with ESRI support, it was suggested that one way to improve processes to allow us to identify and fix any broken views, is after any field deletions, to run a notebook that does the following: Find 'view' layers in ArcGIS Online From the view layers, identify any that have <10 rows of data or are 'empty' (contain data but not responsive) Output the view layers as a csv I have trialled the following code, however it returns no results ("No empty hosted view layers found. Results saved to empty_view_layers.txt"). I know however that there are multiple view layers with less than 10 rows of data but none are being picked up. I'm not quite sure what is going wrong here so any suggestions would be gratefully received. from arcgis.gis import GIS # import necessary libraries
gis = GIS("home") # connect to your GIS
# Function to find empty hosted view layers
def find_empty_view_layers():
empty_view_layers = []
# Search for hosted feature services
for item in gis.content.search(query="type:Feature Service", max_items=10000):
if "View Layer" in item.typeKeywords: # Check if the item is a view layer
# Check if the view layer is empty
feature_count = item.layers[0].query(return_count_only=True) if item.layers else 0
if feature_count <= 10:
empty_view_layers.append(item.title)
return empty_view_layers
# Retrieve and display the empty view layers
empty_layers = find_empty_view_layers()
if empty_layers:
print("Empty Hosted View Layers:")
for layer in empty_layers:
print(f"- {layer}")
else:
print("No empty hosted view layers found.")
# Optionally, save the results to a text file
with open("empty_view_layers.txt", "w") as file:
for layer in empty_layers:
file.write(layer + "\n")
print("Results saved to empty_view_layers.txt") Alternatively, a method for outputting all view layers and their associated feature count would also do the job. I have tried this via the following approach: from arcgis.gis import GIS # import libraries
gis = GIS("home") # connect to your GIS
items = gis.content.search(query='View Service', max_items=10000) # get view layers
for layer in items: # check the output by printing the view layer titles
print(layer.title)
# Loop through the layers and get the feature count
for layer_item in items:
print(f"Layer: {layer_item.title}")
for lyr in layer_item.layers:
feature_count = lyr.query(where="1=1", return_count_only=True)
print(f" Feature Layer: {lyr.properties.name}, Feature Count: {feature_count}") This 2nd approach works to begin with, but then returns the error below. This appears to be caused by it trying to work against a geocoding view. Therefore, is there a way to limit the layer list to only 'hosted, view' type items, or at least exclude a geocoding view? ---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/opt/conda/lib/python3.11/site-packages/arcgis/gis/__init__.py in ?(self, k)
14045 if not self._hydrated and not k.startswith("_"):
14046 self._hydrate()
> 14047 return dict.__getitem__(self, k)
KeyError: 'layers'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
/tmp/ipykernel_142/3627018840.py in ?()
1 # Loop through the layers and get the feature count
2 for layer_item in items:
3 print(f"Layer: {layer_item.title}")
----> 4 for lyr in layer_item.layers:
5 feature_count = lyr.query(where="1=1", return_count_only=True)
6 print(f" Feature Layer: {lyr.properties.name}, Feature Count: {feature_count}")
/opt/conda/lib/python3.11/site-packages/arcgis/gis/__init__.py in ?(self, name)
13999 def __getattribute__(self, name):
14000 if name == "layers":
> 14001 if self["layers"] is None or self["layers"] == []:
14002 try:
14003 with _common_utils._DisableLogger():
14004 self._populate_layers()
/opt/conda/lib/python3.11/site-packages/arcgis/gis/__init__.py in ?(self, k)
14043 return dict.__getitem__(self, k)
14044 except KeyError:
14045 if not self._hydrated and not k.startswith("_"):
14046 self._hydrate()
> 14047 return dict.__getitem__(self, k)
KeyError: 'layers' Thanks in advance for any assistance on this.
... View more
3 weeks ago
|
0
|
0
|
172
|
|
IDEA
|
I agree a way to have certain aspects in 'drafts' would be fantastic.
... View more
11-04-2025
06:03 AM
|
0
|
0
|
310
|
|
POST
|
Same here (UK). Possibly related to Amazon Web Services outage?
... View more
10-20-2025
01:36 AM
|
3
|
0
|
773
|
|
POST
|
Thank you @KenBuja that's fantastic. You've saved me hours of trial and error. This does exactly what I need.
... View more
10-10-2025
01:50 AM
|
0
|
0
|
277
|
|
POST
|
Thank you for taking the time to post this. I had a go with it but Ken's solution does the trick.
... View more
10-10-2025
01:49 AM
|
0
|
0
|
277
|
|
POST
|
I'm wondering if anyone can assist with a data expression, or let me know if what I am aiming for is not possible. I have a dataset from wildlife monitoring, which captures the date of a species observation, the lifestage (e.g. adult, juvenile), the sex (male, female, unsexed) and the quantity (integer) observed. Multiple observations can occur on the same date. Each combination of the above fields is on a separate row (i.e. in 'long' format). Example below. date lifestage sex quantity 01/03/2025 adult male 2 01/03/2025 adult male 5 01/03/2025 juvenile 3 02/03/2025 adult female 8 05/03/2025 metamorph 1 05/03/2025 adult male 3 12/03/2025 adult 12 14/03/2025 adult female 6 14/03/2025 adult female 4 I am trying to use the Dashboards Table element to produce a summary table of this data, where each date is represented as a row, and then subsequent columns show the daily total for each lifestage*sex combination. For example: date adult male adult female adult unsexed juvenile metamorph 01/03/2025 7 0 0 3 0 02/03/2025 0 8 0 0 0 05/03/2025 3 0 0 0 1 12/03/2025 0 0 12 0 0 14/03/82025 0 10 0 0 0 I've gotten so far using Filter and GroupBy statements to summarise counts by day (e.g. resulting in the table format below), but I've not been able to produce a 'wide' format table. Is there any way of doing this? date type total 01/03/2025 adult male 7 01/03/2025 juvenile 3 02/03/2025 adult female 8 I have based my code so far on this example: https://github.com/Esri/arcade-expressions/blob/master/dashboard/dashboard_data/CombineMultipleLayers(SerialChart).md, but instead of referencing different layers for each variable, I have tried setting up multiple FeatureSets from the same layer, each with a different filter applied (e.g. for each 'type' above). I have also produced something similar to my incorrect output above using the List element, but it still doesn't achieve what I am after. Any help would be hugely appreciated.
... View more
10-07-2025
09:40 AM
|
0
|
4
|
346
|
|
POST
|
Three years after submitting this as an enhancement to Esri (ENH-000149200) they have this week decided that the issue will not be addressed. This is extremely disappointing as it remains a major flaw with the system.
... View more
08-29-2025
01:38 AM
|
0
|
0
|
305
|
|
IDEA
|
I think the only alternative currently available would be to have two copies of the same layer, one visualised as points with a set zoom level, and the other showing the polygons at a closer zoom level.
... View more
08-20-2025
07:02 AM
|
0
|
0
|
520
|
|
IDEA
|
Notify hub organisation administrators when hub is down. This comes after an interruption to the service yesterday (https://hubstatus.arcgis.com/). However, rather than notify administrators so that they are aware of the issue, can put workarounds in place, or send out communications to their users, we are currently reliant on (1) having the issue reported to us by a user or noticing it ourselves and then (2) investigating the issue (including checking here on the Community and / or on https://hubstatus.arcgis.com/) and potentially wasting time going through technical support. This wastes a lot of administrator time and that of our user community. An automated email notification to administrators would probably be sufficient.
... View more
07-29-2025
05:41 AM
|
2
|
3
|
436
|
|
POST
|
I agree using either Survey123 to submit messages to the feed, or if you have ArcGIS Hub Premium, making use of the Discussion boards functionality.
... View more
07-28-2025
03:00 AM
|
1
|
1
|
471
|
|
BLOG
|
@JustinPrather the site with no pages was just setup as part of the testing process within the support case, as we wanted to rule out whether having custom domains on our sites was part of the issue. I simply created a Hub (Premium) site and on the home page, added a gallery card containing a single Experience Builder app. The test site is still live publicly at https://testpnf-arc-trust.hub.arcgis.com/ (though I'll probably take it down sometime soon if no longer needed for the case). If a community user is not signed in, the app loads without issue (at the address https://testpnf-arc-trust.hub.arcgis.com/apps/6b22f45264ae43d9b0b8bdc8541accbd/explore). If a community user is signed in and tries to load the app from the gallery card, they receive the 'Page Not Found' error, and the browser URL is instead returned as https://testpnf-arc-trust.hub.arcgis.com/apps/6b22f45264ae43d9b0b8bdc8541accbd/about.
... View more
07-18-2025
06:35 AM
|
0
|
0
|
1457
|
|
BLOG
|
@vBright @JustinPrather we are also seeing some issues of items and pages returning 'Page Not Found' depending on sharing and whether a user is signed in or not. Logged as Esri Case #0395343. This is occurring on existing sites (where we have not yet migrated our pages), and on newly created sites that have no pages.
... View more
07-15-2025
05:35 AM
|
0
|
0
|
1553
|
|
POST
|
ESRI support have confirmed that this is expected behaviour for view layers. Only the owner of a hosted feature layer view or an administrator can define what fields or features are available in the view.
... View more
06-27-2025
01:27 AM
|
0
|
0
|
571
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 10-20-2025 01:36 AM | |
| 1 | 02-24-2021 10:05 AM | |
| 2 | 07-29-2025 05:41 AM | |
| 1 | 07-28-2025 03:00 AM | |
| 1 | 06-26-2025 04:52 AM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|