ArcGIS Pro

Working and sharing the latest from a live data in ArcGIS Pro

Let’s start by opening a sample web application – Tracking Covid-19 across the USA.

If you open this app tomorrow or the day after or even a week later, the map will still give you the very latest as of that day. Click on the Layer List tool, and select View in Attribute Table option for US latest cumulative total table to see the last time the data was updated, and the total confirmed cases and deaths.

You can also get the latest data for any county in the popup window when the Time Slider tool is closed.

Coronavirus is not the only case under which we want to have an app like this; tracking hurricanes, monitoring the water level along rivers, earthquakes, etc. are few examples where data gets updated regularly.

So, how did I achieve this?

First of all, this web map is powered by a sample map service. The authoring and sharing as a map service was just a one time task in ArcGIS Pro. And it was done in a way that:

Let’s take a look at what I did as a response to inquiries about this directed towards my previous blog.

Let’s get some data

We will use the New York Times coronavirus data. If you already have it, that is great! Otherwise, use steps from my last blog post to get data, and make sure to keep it updated daily.

Once you follow the instructions, you will have:

Step 1: copy data to an enterprise database

Step 2: create a query layer

  1. Choose Add Data | Query Layer option on the Map ribbon.
    Help link: Create a query layer—Query layers
  2. Select a database connection.
  3. Provide a name, such as “NYTCounty_Covid19”.
  4. Enter a SQL like the below
    SELECT     c.*,
    t.date, t.cases, t.deaths
    FROM       nytcovid19_counties c
    INNER JOIN nytcovid19_timeseriescases t
    ON         c.fips = t.fips
    Note: make sure the table names and field names are matched with what you have in your database.

At this point, the SQL statement simply defines and joins two tables, and if you were to validate it and go ahead with creating the layer, you will see a feature layer with multiple records for each county. Multiple polygons are overlapped for each county. We don’t want that, so we need to restrict it, returning only records matching time span set in ArcGIS Pro Time Slider. We will do this by adding a where clause with a relatively new but very powerful range parameter. (Please note: we really don’t need to have a range parameter to make this a time aware layer, but we do need it for Step 4 below and some advanced capability that I will discuss in my next blog).

Step 3: add a time range parameter

  1. Add the following line at the end of the SQL you added in the previous section.
    WHERE ::r:datetime
  2. Click the pencil icon.
  3. Enter date in the Field or Expression textbox.
  4. Choose Date from the Data Type drop down.
  5. Expand the Advanced section and enter the table name where the date field belongs.

A range parameter of Date data type automatically gets used to make the layer time aware. At that point, you can use time slider to see counties with data within the selected time window.

Step 4: set default values to draw counties with their latest data

  1. Check Default value check box, if it is not already checked.
  2. If you use PostgreSQL database, enter the following SQL expression in the first text box. Otherwise, see the notes section below.
    (select max(date) - interval '23 hours 59 min 59 sec' from nytcovid19_timeseriescases)
  3. Enter the following SQL expression in the second text box.
    (select max(date) from nytcovid19_timeseriescases)
  4. Click Done.

These default values get used when the Time Slider is not enabled or used. Therefore, when the time slider is not in use, the layer will use these default values to retrieve the latest data from the table – and you will see a map showing the current state. To get the count for each county for any given day, you can enable time slider and slide to that date.

Notes:

Step 5: validate and finish creating a query layer

  1. Click Validate.
  2. Click Next.
  3. On the next page, have objectid field checked from the Unique Identified Field(s): list.
  4. The Spatial Properties section should get populated here. If not, you might need to go back and check the SQL which might not be returning any features. This section requires the SQL statement returns at least one feature to retrieve these properties.
  5. Click Finish.

Step 6: symbolize and use time slider

View latest data:

View data from any other date

Step 7: share your map as a map service

Step 8: consuming the map service in a web map

Showing latest data off file geodatabase

 

Coming up next:

As you might have noticed, the web map has few additional attributes and tables coming from the back-end map service such as daily counts for counties, also aggregated to states and counties, plus 7 day and 4 day rolling average. These additional attributes were not part of the original New York Times data; instead, they were computed from the original dataset by taking advantage of database functionality and ArcGIS Pro capability.

In my next blog post, I will discuss how I prepared such data and shared it as a map service so that a dashboard application, like the image below, can be created. In the meantime, you can take a look at a sample one here: https://arcg.is/0Ojyyv.

A simple dashboard app showing the current state of coronavirus spread in the USA and charts showing trends at national, state or county level.

Also, please take a look at the content of the map service: https://sampleserver6.arcgisonline.com/arcgis/rest/services/NYTimes_Covid19Cases_USCounties/MapServer.

About the author

Tanu is a product engineer on Esri Mapping Team focusing on map service, print service, and ArcGIS Pro. He also works on spatio-temporal analysis, spatial aggregation and real-time data. Tanu’s background includes a masters in Urban Planning from University of Akron, Ohio, USA and a bachelor degree from Khulna University, Bangladesh, and worked as GIS Coordinator in City of West Springfield, and GIS Specialist in a hydrology modeling center in Bangladesh before joining Esri.

Connect:

Leave a Reply

Please Login to comment

Next Article

Learn How to Download a SSL Certificate for a Secured Portal

Read this article