ArcGIS Developers
Dashboard

ArcGIS API for Python

Mapping the 2019 Novel Coronavirus Pandemic

According to WHO, 2019 Novel Corona Virus (COVID-19) is a virus (more specifically, a coronavirus) identified as the cause of an outbreak of respiratory illness, which was unknown before the outbreak began in Wuhan, China, in December 2019 [1]. Early on, the disease demonstrated an animal-to-person spread, then a person-to-person spread. Infections with COVID-19, were reported in a growing number of international locations, including the United States". The United States reported the first confirmed instance of person-to-person spread with this virus on January 30, 2020 [2].

This notebook shows how to use the ArcGIS API for Python to monitor the spread of COVID-19 as it became a pandemic (updated as of June 28th, 2021).

1. Import Data

Esri provides an open-to-public and free-to-share feature layer that contains the most up-to-date COVID-19 cases covering China, the United States, Canada, Australia (at province/state level), and the rest of the world (at country level, represented by either the country centroids or their capitals). Data sources are WHO, US CDC, China NHC, ECDC, and DXY. The China data is updated automatically at least once per hour, and non-China data is updating manually. The data source repo that this layer referenced from, is created and maintained by the Center for Systems Science and Engineering (CSSE) at the Johns Hopkins University, and can be viewed here. In this notebook, we will use the feature layer supported by Esri Living Atlas team and JHU Data Services, and provide a different perspective in viewing the global maps of COVID-19 via the use of ArcGIS API for Python.

NOTE: "Since COVID-19 is continuously evolving, the sample reflects data as of June 28th, 2021 (or if you are looking at a previously published version of this notebook, the data and maps were fetched/made as of July 4th, 2020). Running this notebook at a later date might reflect a different result, but the overall steps should hold good."

DISCLAIMER: "This notebook is for the purpose of illustrating an analytical process using Jupyter Notebooks and ArcGIS API for Python, and should not be used as medical or epidemiological advice."

Necessary Imports

In [1]:
from io import BytesIO
import requests
import pandas as pd
from arcgis.features import FeatureLayer
from arcgis.gis import GIS
from arcgis.mapping import WebMap
In [2]:
"""
# if you are using arcgis api for python with version 1.8.0 or above,
# make sure that the pandas version>=1.0,
# if not, use `pip install --upgrade pandas>=1` to upgrade.
"""
pd.__version__
Out[2]:
'1.2.3'

Get data for the analysis

Query the source feature layer

The dashboard item contributed to the public by Esri and JHU CSSE, is accessible through here:

In [3]:
gis = GIS(profile="your_online_profile")
In [8]:
item = gis.content.search("Coronavirus_2019_nCoV_Cases owner:CSSE_covid19", outside_org=True)[0]
item
Out[8]:
Coronavirus COVID-19 (2019-nCoV)
This ArcGIS Dashboard created by the CSSE Team at Johns Hopkins contains the most up-to-date coronavirus COVID-19 (2019-nCoV) cases and latest trend plot.Dashboard by CSSE_covid19
Last Modified: June 03, 2021
0 comments, 301,342,595 views

Through the API Explorer provided along with the dashboard product, we can easily fetch the source URL for the Feature Service containing daily updated COVID-19 statistics, which can then be used to create a FeatureLayer object good for querying and visualizing.

In [9]:
src_url = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/Coronavirus_2019_nCoV_Cases/FeatureServer/1"
fl = FeatureLayer(url=src_url)
In [10]:
df_global = fl.query(where="1=1",
                     return_geometry=True,
                     as_df=True)

As stated in the dashboard, the source data can be grouped into:

  • A. Countries or regions of which data are collected at province/state level, e.g. China, the United States, Canada, Australia;
  • B. Countries or regions for the rest of the world of which data collected at country level, and shape represented by either the country centroids or their capitals;
  • C. Cruise Ships with confirmed COVID-19 cases.
Group A

Let us first take a look at how many countries are within group A, that Country_Region and Province_State are not null or NAN.

In [11]:
df_global[~pd.isnull(df_global['Province_State'])].groupby('Country_Region').sum()[['Confirmed', 'Recovered', 'Deaths']]
Out[11]:
Confirmed Recovered Deaths
Country_Region
Australia 30528 23781 910
Belgium 1082476 0 25160
Brazil 18420598 16160826 513474
Canada 1421009 1385623 26188
Chile 1547103 1484410 32298
China 103727 98331 4847
Colombia 4158716 3854457 104678
Denmark 822 798 1
France 128701 64102 1069
Germany 3734597 3619010 90777
India 30279331 29309607 396730
Italy 4258069 4073435 127472
Japan 797079 763208 14659
Mexico 2505792 1990610 232564
Netherlands 1711530 27290 18024
New Zealand 1 0 0
Pakistan 955657 901201 22231
Peru 2048115 2007201 191899
Russia 5408744 4911752 131671
Spain 3792642 150376 80789
Sweden 1088896 0 14619
US 33631532 0 604030
Ukraine 2298478 2221380 54517
United Kingdom 4771289 15724 128367

Each country/region in Group A, has more than 1 feature, as what we have seen below from the query() results.

In [12]:
fset_usa = fl.query(where="Country_Region='US'")
fset_usa
Out[12]:
<FeatureSet> 60 features
In [13]:
fset_china = fl.query(where="Country_Region='China'")
fset_china
Out[13]:
<FeatureSet> 34 features
In [14]:
fl.query(where="Country_Region='Denmark'")
Out[14]:
<FeatureSet> 3 features
Group C

Group C contains cruise ships across the globe with reported cases:

In [11]:
df_cruise_ships = fl.query(where="Province_State='Diamond Princess' or \
                                  Province_State='Grand Princess' or \
                                  Country_Region='MS Zaandam' or \
                                  Country_Region='Diamond Princess'",
                           as_df=True)
In [12]:
df_cruise_ships[["Province_State", "Country_Region", "Last_Update", "Confirmed", "Recovered", "Deaths"]]
Out[12]:
Province_State Country_Region Last_Update Confirmed Recovered Deaths
0 Diamond Princess Canada 2020-07-05 00:34:01 0 0 1
1 Grand Princess Canada 2020-07-05 00:34:01 13 13 0
2 None Diamond Princess 2020-07-05 00:34:01 712 651 13
3 None MS Zaandam 2020-07-05 00:34:01 9 0 2
4 Grand Princess US 2020-07-05 00:34:01 103 0 3
5 Diamond Princess US 2020-07-05 00:34:01 49 0 0
Group B

In the df_global, other than the 22 countries (Australia, Canada, China, etc.) in Group A, and those cruise ships in Group C, all other countries/regions fall into Group B, e.g. Thailand. The major difference between Group A and Group B is that the latter contains one and only feature per country.

In [17]:
fl.query(where="Country_Region='Thailand'")
Out[17]:
<FeatureSet> 1 features

Query the reference feature layers

Because the geo-information provided by the dashboard contains only the coordinates representing the centroid of each country/region, the feature layer can only be rendered as points on Map. If this is what you want, you can now skip the rest of section 1, and jump right onto section 2.

On the other hand, if you want to visualize the confirmed/death/recovered cases per country/region as polygons, in other words as a choropleth map, please read along:

First, we need to access the feature service that contains geometry/shape info for all provinces in Mainland China, and merge with the COVID-19 DataFrame.

Access the reference feature layer of China
In [18]:
provinces_item = gis.content.get("0f57da7f853c4a1aa5b2e048ff8655d2")
provinces_item
Out[18]:
Merged_China_Province_Boundaries_2018
Feature layer generated from Merge LayersFeature Layer Collection by api_data_owner
Last Modified: July 04, 2020
0 comments, 15 views
In [19]:
provinces_flayer = provinces_item.layers[0]
provinces_df = provinces_flayer.query(as_df=True)
provinces_df.columns
Out[19]:
Index(['OBJECTID', 'ID', 'NAME', 'AREA', 'TOTPOP_CY', 'ISO_CODE', 'ISO_SUB',
       'ISO2_CC', 'ISO3_CC', 'Shape__Area', 'Shape__Length', 'ID_1',
       'sourceCountry', 'ENRICH_FID', 'aggregationMethod',
       'populationToPolygonSizeRating', 'apportionmentConfidence', 'HasData',
       'TOTPOP_CY_1', 'YEAR2018', 'SHAPE'],
      dtype='object')
In [20]:
tmp = provinces_df.sort_values('NAME', ascending=True)
provinces_df = tmp.drop_duplicates(subset='NAME', keep='last')
provinces_df.shape
Out[20]:
(31, 21)
DataFrame Merging for China Dataset

The subsets of dataframe being created in the previous section now needs to be merged with feature services which have geographic information (e.g. geometries, shape, or longitude/latitude) in order to provide location and geometries required for geographic mapping. First, let's acquire the geometries from feature services existing on living atlas or arcgis online organization to represent the geographic information needed of overlap_rows_china.

In [21]:
df_china = fset_china.sdf[['Province_State', 'Confirmed', 'Recovered', 'Deaths']]
df_china = df_china.assign(NAME = df_china["Province_State"])
df_china.head()
Out[21]:
Province_State Confirmed Recovered Deaths NAME
0 Anhui 1004 998 6 Anhui
1 Beijing 1078 1054 9 Beijing
2 Chongqing 598 591 6 Chongqing
3 Fujian 672 620 1 Fujian
4 Gansu 195 192 2 Gansu

Because the names are inconsistent between the two data sources (e.g. provinces represented differently in df_china['Province_State'] and provinces_df['NAME"]), the replace_value_in_column method is declared below to edit the records and unify the column names.

In [22]:
def replace_value_in_column(data_frame, l_value, r_value, column_name = 'NAME'):
    data_frame.loc[data_frame[column_name] == l_value, column_name] = r_value

replace_value_in_column(df_china, 'Guangxi', 'Guangxi Zhuang Autonomous Region')
replace_value_in_column(df_china, 'Inner Mongolia', 'Inner Mongolia Autonomous Region')
replace_value_in_column(df_china, 'Ningxia', 'Ningxia Hui Autonomous Region')
replace_value_in_column(df_china, 'Tibet', 'Tibet Autonomous Region')

Now the two DataFrame objects have got unified column names, we can go ahead to use a single function in Pandas called merge as an entry point to perform in-memory standard database join operations (similar to that of relational databases such as SQL), and its syntax is shown here -

pd.merge(left, right, how='inner', on=None, left_on=None, right_on=None,
         left_index=False, right_index=False, sort=True)

Note that, the how argument specifies how to merge (a.k.a. how to determine which keys are to be included in the resulting table). If a key combination does not appear in either the left or the right tables, the values in the joined table will be NA. The table below then shows a summary of the how options and their SQL equivalent names −

Merge Method SQL Equivalent Description
left LEFT OUTER JOIN Use keys from left object
right RIGHT OUTER JOIN Use keys from right object
outer FULL OUTER JOIN Use union of keys
inner INNER JOIN Use intersection of keys

In this case, we will be calling merge() with how='inner' to perform the inner join of the two DataFrame objects on the index field "NAME" and only to keep the intersection of keys.

In [23]:
cols_2 = ['NAME', 'AREA', 'TOTPOP_CY','SHAPE']
overlap_rows_china = pd.merge(left = provinces_df[cols_2], right = df_china, 
                              how='inner', on = 'NAME')
overlap_rows_china.head()
Out[23]:
NAME AREA TOTPOP_CY SHAPE Province_State Confirmed Recovered Deaths
0 Anhui 140139.795987 61795934 {'rings': [[[116.36710167, 34.643320083], [116... Anhui 1004 998 6
1 Beijing 16535.630276 22237467 {'rings': [[[116.647890001, 41.0513740000001],... Beijing 1078 1054 9
2 Chongqing 82390.600691 30365055 {'rings': [[[108.50186348, 32.20025444], [108.... Chongqing 598 591 6
3 Fujian 121789.666833 38659398 {'rings': [[[118.426801682, 28.2953205110001],... Fujian 672 620 1
4 Gansu 401138.394581 26268236 {'rings': [[[97.1721363070001, 42.793840408000... Gansu 195 192 2
In [24]:
cols_2 = ['NAME', 'AREA', 'TOTPOP_CY','SHAPE','Shape__Area', 'Shape__Length']
overlap_rows_china = pd.merge(left = provinces_df[cols_2], right = df_china, how='inner',
                        on = 'NAME')
overlap_rows_china.head()
Out[24]:
NAME AREA TOTPOP_CY SHAPE Shape__Area Shape__Length Province_State Confirmed Recovered Deaths
0 Anhui 140139.795987 61795934 {'rings': [[[116.36710167, 34.643320083], [116... 13.352904 32.965496 Anhui 1004 998 6
1 Beijing 16535.630276 22237467 {'rings': [[[116.647890001, 41.0513740000001],... NaN NaN Beijing 1078 1054 9
2 Chongqing 82390.600691 30365055 {'rings': [[[108.50186348, 32.20025444], [108.... 7.708492 30.308633 Chongqing 598 591 6
3 Fujian 121789.666833 38659398 {'rings': [[[118.426801682, 28.2953205110001],... 10.989105 54.634113 Fujian 672 620 1
4 Gansu 401138.394581 26268236 {'rings': [[[97.1721363070001, 42.793840408000... 41.085703 80.438096 Gansu 195 192 2

As shown in overlap_rows_china, each province/state in China is now merged while retaining the SHAPE column, and is ready to be rendered as polygons.

Access the reference feature layer of the United States

Next, we need to access the feature service that contains geometry/shape info for all states in the U. S., and merge with the DataFrame depicting COVID-19 statistics.

In [25]:
us_states_item = gis.content.get('99fd67933e754a1181cc755146be21ca')
us_states_item
Out[25]:
USA States (Generalized)
USA States (Generalized) provides 2017 boundaries for the States of the United States in the 50 states and the District of Columbia.Feature Layer Collection by esri_dm
Last Modified: June 21, 2021
0 comments, 466,257,725 views
In [26]:
us_states_flayer = us_states_item.layers[0]
us_states_df = us_states_flayer.query(as_df=True)
us_states_df.columns
Out[26]:
Index(['FID', 'STATE_NAME', 'STATE_FIPS', 'SUB_REGION', 'STATE_ABBR',
       'POPULATION', 'POP_SQMI', 'POP2010', 'POP10_SQMI', 'WHITE', 'BLACK',
       'AMERI_ES', 'ASIAN', 'HAWN_PI', 'HISPANIC', 'OTHER', 'MULT_RACE',
       'MALES', 'FEMALES', 'AGE_UNDER5', 'AGE_5_9', 'AGE_10_14', 'AGE_15_19',
       'AGE_20_24', 'AGE_25_34', 'AGE_35_44', 'AGE_45_54', 'AGE_55_64',
       'AGE_65_74', 'AGE_75_84', 'AGE_85_UP', 'MED_AGE', 'MED_AGE_M',
       'MED_AGE_F', 'HOUSEHOLDS', 'AVE_HH_SZ', 'HSEHLD_1_M', 'HSEHLD_1_F',
       'MARHH_CHD', 'MARHH_NO_C', 'MHH_CHILD', 'FHH_CHILD', 'FAMILIES',
       'AVE_FAM_SZ', 'HSE_UNITS', 'VACANT', 'OWNER_OCC', 'RENTER_OCC',
       'NO_FARMS12', 'AVE_SIZE12', 'CROP_ACR12', 'AVE_SALE12', 'SQMI',
       'Shape__Area', 'Shape__Length', 'GlobalID', 'SHAPE'],
      dtype='object')
DataFrame Merging for U.S. Dataset
In [27]:
df_usa = fset_usa.sdf[['Province_State', 'Confirmed', 'Recovered', 'Deaths']]
df_usa = df_usa.assign(STATE_NAME = df_usa["Province_State"])
df_usa.head()
Out[27]:
Province_State Confirmed Recovered Deaths STATE_NAME
0 Mississippi 321138 0 7401 Mississippi
1 Grand Princess 103 0 3 Grand Princess
2 Oklahoma 457571 0 7384 Oklahoma
3 Delaware 109682 0 1694 Delaware
4 Minnesota 605218 0 7680 Minnesota
In [28]:
cols_4 = ['STATE_NAME','SHAPE']
overlap_rows_usa = pd.merge(left = us_states_df[cols_4], right = df_usa, 
                            how='inner', on = 'STATE_NAME')
overlap_rows_usa.head()
Out[28]:
STATE_NAME SHAPE Province_State Confirmed Recovered Deaths
0 Alaska {'rings': [[[-17959594.8053098, 8122953.575198... Alaska 71035 0 374
1 California {'rings': [[[-13543710.3257494, 4603367.827345... California 3816296 0 63593
2 Hawaii {'rings': [[[-17819334.303422, 2512026.7784964... Hawaii 37647 0 516
3 Idaho {'rings': [[[-13027307.5891034, 5415905.134774... Idaho 194719 0 2145
4 Nevada {'rings': [[[-13263990.1054907, 4637763.931898... Nevada 331614 0 5667
Access the reference feature layer of world countries
In [29]:
countries_item = gis.content.get('2b93b06dc0dc4e809d3c8db5cb96ba69')
countries_item
Out[29]:
World Countries (Generalized)
World Countries (Generalized) provides optimized country boundaries with useful name and country code attributes. Current to January 2020.Feature Layer Collection by esri_dm
Last Modified: April 14, 2021
1 comments, 34,158,950 views
In [30]:
countries_flayer = countries_item.layers[0]
countries_df = countries_flayer.query(as_df=True)
countries_df.columns
Out[30]:
Index(['FID', 'COUNTRY', 'ISO', 'COUNTRYAFF', 'AFF_ISO', 'Shape__Area',
       'Shape__Length', 'SHAPE'],
      dtype='object')
DataFrame Merging for global Dataset

The df_global has listed its Country_Region column with their current best-known names in English, while the countries_df uses their currently best-known equivalents, and this difference in naming countries has created a problem for the merge() operation to understand if the two countries listed in two DataFrame objects are the same. We need to hence run the following cell in order to make country names consistent between the two DataFrames to be merged.

In [31]:
df_global.loc[df_global['Country_Region']=='US', 'Country_Region'] = 'United States'
df_global.loc[df_global['Country_Region']=='Korea, South', 'Country_Region'] = 'South Korea'
df_global.loc[df_global['Country_Region']=='Korea, North', 'Country_Region'] = 'North Korea'
df_global.loc[df_global['Country_Region']=='Russia', 'Country_Region'] = 'Russian Federation'
df_global.loc[df_global['Country_Region']=='Czechia', 'Country_Region'] = 'Czech Republic'
List the top 10 countries with largest numbers

With df_global ready, we can now sort countries or regions by their numbers of confirmed/recovered/death cases, through usage of groupby(), and sort_values().

In [32]:
# sorted by # of confirmed cases
df_global_sum = df_global.groupby('Country_Region').sum()[['Confirmed', 'Recovered', 'Deaths']]
df_global_sum_c = df_global_sum.sort_values(by = ['Confirmed'], ascending = False)
df_global_sum_c.head(10)
Out[32]:
Confirmed Recovered Deaths
Country_Region
United States 33631532 0 604030
India 30279331 29309607 396730
Brazil 18420598 16160826 513474
France 5832225 404395 111130
Turkey 5414310 5280558 49634
Russian Federation 5408744 4911752 131671
United Kingdom 4771289 15724 128367
Argentina 4405247 4027510 92568
Italy 4258069 4073435 127472
Colombia 4158716 3854457 104678
In [33]:
# sorted by death tolls
df_global_sum_d = df_global_sum.sort_values(by = ['Deaths'], ascending = False)
df_global_sum_d.head(10)
Out[33]:
Confirmed Recovered Deaths
Country_Region
United States 33631532 0 604030
Brazil 18420598 16160826 513474
India 30279331 29309607 396730
Mexico 2505792 1990610 232564
Peru 2048115 2007201 191899
Russian Federation 5408744 4911752 131671
United Kingdom 4771289 15724 128367
Italy 4258069 4073435 127472
France 5832225 404395 111130
Colombia 4158716 3854457 104678
Joining the COVID-19 stats and world countries DataFrames
In [34]:
world_merged1 = pd.merge(df_global_sum_c, countries_df[['COUNTRY', 'SHAPE']], 
                         left_index=True, right_on='COUNTRY',
                         how="left")
world_merged1[['COUNTRY', 'Confirmed','Deaths', 'Recovered']].head(10)
Out[34]:
COUNTRY Confirmed Deaths Recovered
154.0 United States 33631532 604030 0
193.0 India 30279331 396730 29309607
20.0 Brazil 18420598 513474 16160826
155.0 France 5832225 111130 404395
151.0 Turkey 5414310 49634 5280558
246.0 Russian Federation 5408744 131671 4911752
89.0 United Kingdom 4771289 128367 15724
14.0 Argentina 4405247 92568 4027510
170.0 Italy 4258069 127472 4073435
37.0 Colombia 4158716 104678 3854457

Now, each country/region in world_merged1 is now merged with the SHAPE column, and is ready to be rendered as polygons.

2. Map the COVID-19 cases in China

Next, let us start visualizing the following scenarios targeting at China:

  • Confirmed cases rendered as points, and polygons
  • Death cases rendered as points, and polygons
  • Recovered cases rendered as points, and polygons

Map the confirmed COVID-19 cases in China

We can either call the add_layer() function to add the specified layer or item (i.e. the FeatureLayer object created as fl) to the map widget, and set the visualization options to be using ClassedSizeRenderer, or plot the derived SeDF on the map view directly with further descriptions such as how to renderer spatial data using symbol and color palette (Here, the SeDF is the derivative of the merged DataFrame, which now contains a SHAPE column that we can use to plot in the Map widget as polygons).

Display confirmed cases in China as points

In [30]:
map1 = gis.map('China', zoomlevel=4)
map1
Out[30]:
In [28]:
map1.add_layer(fl,   { "type": "FeatureLayer",
                       "renderer":"ClassedSizeRenderer",
                       "field_name":"Confirmed"})
In [29]:
map1.zoom = 3
map1.legend = True

Display confirmed cases in China as polygons

In [26]:
map1b = gis.map('China')
map1b
Out[26]:
In [44]:
map1b.clear_graphics()
overlap_rows_china.spatial.plot(  kind='map', map_widget=map1b,
                                  renderer_type='c',  # for class breaks renderer
                                  method='esriClassifyNaturalBreaks',  # classification algorithm
                                  class_count=4,  # choose the number of classes
                                  col='Confirmed',  # numeric column to classify
                                  cmap='inferno',  # color map to pick colors from for each class
                                  alpha=0.7  # specify opacity
                                 )
Out[44]:
True
In [45]:
map1b.zoom = 4
map1b.legend=True

The Map view above (map1b) displays the number of confirmed cases per province in Mainland China. Orange polygons refer to provinces with number of confirmed cases in the range of [45423, 68134], and black polygons represent those in the range of [1, 22712].

Also, we can save the MapView object into a Web Map item for the purpose of future references and modifications.

In [46]:
map1b.save({'title':'Confirmed COVID-19 Cases in China',
            'snippet':'Map created using Python API showing confirmed COVID-19 cases in China',
            'tags':['automation', 'COVID19', 'world health', 'python']})
Out[46]:
Confirmed COVID-19 Cases in China
Map created using Python API showing confirmed COVID-19 cases in ChinaWeb Map by arcgis_python
Last Modified: July 04, 2020
0 comments, 0 views

For example, we can browse the web map in the browser, change its symbology to different color maps in the configuration pane, then visualize it again with different looks here.

In [51]:
map1b_item = gis.content.search('Confirmed COVID-19 Cases in China')[0]
WebMap(map1b_item)
Out[51]:

Map the deaths caused by COVID-19 in China

Display death cases in China as points

In [34]:
map2 = gis.map('China', zoomlevel=4)
map2
Out[34]:
In [32]:
map2.add_layer(fl,   { "type": "FeatureLayer",
                       "renderer":"ClassedSizeRenderer",
                       "field_name":"Deaths"})
In [33]:
map2.legend = True

Display death cases in China as polygons

In [52]:
map2b = gis.map('China')
map2b
In [40]:
map2b = gis.map('China')
map2b
Out[40]:
In [53]:
map2b.clear_graphics()
overlap_rows_china.spatial.plot(  kind='map', map_widget=map2b,
                                  renderer_type='c',  # for class breaks renderer
                                  method='esriClassifyNaturalBreaks',  # classification algorithm
                                  class_count=4,  # choose the number of classes
                                  col='Deaths',  # numeric column to classify
                                  cmap='inferno',  # color map to pick colors from for each class
                                  alpha=0.7  # specify opacity
                                 )
Out[53]:
True
In [54]:
map2b.zoom = 4
map2b.legend = True

Using the same approach, we can then map the number of death cases per province in Mainland China. With legend displayed, map2b shows us orange polygons refer to provinces with number of death cases in the range of [3008, 4512], and black polygons represent those in the range of [0, 1504].

Similarly, we can create an additional deliverable - the Web Map Item created on the active GIS - and then browse the web map in the browser, change its symbology to different color maps in the configuration pane, and/or visualize it again with different looks here.

In [55]:
map2b_item = map2b.save({'title':'COVID-19 Death Cases in China',
                         'snippet':'Map created using Python API showing COVID-19 death cases in China',
                         'tags':['automation', 'COVID19', 'world health', 'python']})
In [58]:
WebMap(map2b_item)
Out[58]:

Map the recovered COVID-19 cases in China

Display the recovered cases in China as points

In [44]:
map3 = gis.map('China', zoomlevel=4)
map3
Out[44]:
In [42]:
map3.add_layer(fl,   { "type": "FeatureLayer",
                       "renderer":"ClassedSizeRenderer",
                       "field_name":"Recovered"})
In [43]:
map3.legend = True

Display the recovered cases in China as polygons

In [48]:
map3b = gis.map('China')
map3b
Out[48]: