Only show last 24 hours of data on an AGOL web map

5863
7
Jump to solution
09-21-2015 09:34 AM
Jay_Gregory
Occasional Contributor III

I have a time-enabled feature class that grows by about 60 events each day (it is currently up to about 100k events). This feature class is published to a ArcGIS for Server 10.3 instance.  I've been messing around with the "filter" option for layers in AGOL.  I can set a filter to display events for a specific day or a date range, but I'm curious if it's possible to have a web map always just display the last 24 hours of events.  It doesn't look like it can be done with the filter option as it has no understanding of "today" or even timestamps (just dates) - is there a way to update the filter on an AGOL web map programatically, so every five minutes it updates the query to only retrieve the last 24 hours of data? 

Alternatively, would the only other way to achieve this effect be to create a second feature class that is itself updated every 5 minutes to only include the last 24 hours of data from the first feature class.  Then expose the "subset" feature class to ArcGIS Server and build my webmap off that? It seems inefficient, but I'm struggling to determine the best way to do this.

Thanks in advance!

Jay

PS - I haven't yet explored geoevent processor fully and don't know if this extension would make this more possible/efficient or not.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ThomasColson
MVP Frequent Contributor

If this is on your own ArcGIS Server, you can use SQL/SDE to host the raw data, then publish from a SQL view that queries based on date/time. I'm doing a variation of that, with some stored procedures that update a feature class with the last 7 days worth of data, every 2 hours, for a wildlife tracking app where folks only want to see recent animal movement in Portal.

View solution in original post

0 Kudos
7 Replies
ThomasColson
MVP Frequent Contributor

If this is on your own ArcGIS Server, you can use SQL/SDE to host the raw data, then publish from a SQL view that queries based on date/time. I'm doing a variation of that, with some stored procedures that update a feature class with the last 7 days worth of data, every 2 hours, for a wildlife tracking app where folks only want to see recent animal movement in Portal.

0 Kudos
Jay_Gregory
Occasional Contributor III

Thanks so much! I thought it might be something like this. Not having a ton of experience with SQL, would I be able to create this SQL view using ArcGIS tools, or will I need to use Management Studio? And once the view is created, I assume I publish it like any other feature class, and the underlying data table keeps getting updated from the raw data at some specified interval?

Thanks again!

0 Kudos
ThomasColson
MVP Frequent Contributor

There are ArcTool Box and ArcMap tools for creating views, I'm not real familiar with them...I prefer going through SSMS where I can have more control over the process, then, Arc Map, Add Data, Query Layer, cut and paste the query syntax.

0 Kudos
NathanDaniels
New Contributor III

I too would find this feature helpful.

I have a task where the Collector and Dashboard have their separate Web Maps but share the same Feature Service. I therefore don't think that the published query method will work. For example, what if someone is a using the queried subset data in Collector, then how are these edits to be reflected back to Dashboard that is linked to the master Feature Service?

I am wondering if there is any other way to automate a last 24 hour AGOL Web Map filter?

0 Kudos
simoxu
by MVP Regular Contributor
MVP Regular Contributor

Use ArcGIS Online Assistant  you can change the code behind the GUI.

see my answer for this post. hope it helps.

Re: Filtering features in WebMaps based on current date

Jay_Gregory
Occasional Contributor III

Thanks so much!  This was incredibly helpful!  For what it's worth, maybe because I'm using SQL 2012 combined with ArcGIS Server 10.3, the query I had to use was eventDate >= CURRENT_DATE - 1.  The DATEADD function was not working.  I was able to test what worked by trying different search strings in the WHERE field of the REST endpoint, and then just copying the correct string into the AGOL assistant.  Anyway, if I didn't know about this assistant, I wouldn't have been able to do this, so thanks for the tip!

0 Kudos
simoxu
by MVP Regular Contributor
MVP Regular Contributor

No worries. I am glad it's useful for you.

You can also update an item using REST API, which I believe it is the underlying stuff ago-assistant is using. but ago assistant is no doubt the easiest way to go, and I like its elegant interface.

0 Kudos