In SAS Visual Analytics, you can quickly create geography data items based on a number of predefined geographies and regions, such as country and region names, state and province names, US state names and abbreviations, and ZIP codes. As long as your CAS table has one of those data items, you can create a geo map. However, there may be times when you need to create a geo map of a region not defined automatically in SAS Visual Analytics. For example, you may need to create geo maps showing custom regions such as sales areas, counties, school districts, or many other possibilities.
In many cases, polygons representing the areas you would like to visualize already exist in some other format, whether it is a shapefile, a geodatabase, or an Esri feature service – it's just a question of using them in SAS Visual Analytics. This article will cover creating custom polygons using an Esri feature service.
Esri feature services are geospatial layers that have been created in ArcGIS software and then published to ArcGIS online or hosted on an organization’s Esri server. Many organizations, such as government agencies and Esri itself, maintain large collections of feature services representing many different possible geographies. These can easily be used to create custom region maps in Visual Analytics.
To use custom polygons in SAS Visual Analytics, you must create a new geographic data provider. There are a few requirements that must be met to do this. You must have administrative privileges in SAS Viya to be able to define and edit geographic data providers. Specifically, you must have Create, Delete, and Update permission for the /maps/providers URI. For more information, see here. If you’re using an Esri feature layer hosted on your organization's own Esri server, then you will need to specify the credentials for that server in the Esri Custom Services Credentials setting. For more information, see here.
Once you have confirmed that you have the necessary permissions and authenticated to your organization’s Esri service (if necessary), then creating a geographic data provider using an Esri feature service involves three steps:
I will walk through each of these steps in more detail below.
In this example, I'll use a table of housing units per block group from the US Census Bureau (available here) to create a geo region map of the number of housing units per Census Block Group in Wake County, North Carolina. Since Census Block Groups are not one of the built-in geographies in Visual Analytics, I'll need to create a new geographic data provider. The Wake County government has published an Esri feature service of the block group boundaries, which can be found here.
The URL that we need to copy is not the URL of the webpage, but of the feature service itself. This can be found on the bottom right-hand side of the page, underneath the Credits section.
Next, I’ll create a new geographic data provider using the Esri feature service. I’ll create a new geographic data item based on the category I want to map (in this case, the Block Group).
Then, in the Edit Geography Item window, I'll select Geographic data provider for the Geography data source and click New Provider. I’ll enter a name and select Esri feature service for the Type.
In the New Geographic Data Provider window, I’ll enter a name and select Esri feature service for the Type. In the URL field, I’ll paste the URL I copied from the Esri feature service webpage. I’ll also specify the type of geometry: point or polygon. In this example, I’ll choose Polygon.
The geographic data provider doesn’t contain the data being mapped. It just contains information about how to draw polygons on a geo map. I need to tell SAS which polygon in the geographic data provider corresponds with which row in the CAS table being mapped (in this example, the table of housing units in Wake County). I can do this by specifying a common ID column in both the CAS table and the Esri feature service. The ID value needs to uniquely identify each feature (in this case, each Census Block Group), and it needs to be common between both the Esri feature service and the CAS table. For example, Census Block Group 1 needs to have the same ID value in both the Esri feature service and the CAS table.
On the Esri feature service webpage, I can examine the attribute table by clicking the Data tab.
It looks like the GEOID column in the feature service corresponds to the ID column in the CAS table. Note that the names of these columns don’t have to match – just the values. For example, the ID values all begin with 37 for the state of North Carolina, followed by 183 for Wake County, and so on.
In the New Geographic Data Provider window, I’ll select the ID column from the Esri feature service – GEOID.
Then in the Edit Geography Item window, I’ll select the ID column I just identified from the CAS table – ID, in this example. Remember, specifying the ID column in both the geographic data provider and the geography data item allows Visual Analytics to associate individual rows in the CAS table to individual polygons from the Esri feature service. In this example, each polygon in the geographic data provider is one Census Block Group, and each row in the CAS table contains information about the number of housing units in a single Census Block Group.
Finally, I’ll create a geo region map using this new geography data item.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.