In this blog post I will share how to create an SAP Analytics Cloud (SAC), Geo Map based on Calculation Views created within the WebIDE. These are Calc Views that reside within an HDI Container as Column Views.
1. HANA Cloud / HANA On-Prem with XSA
2. Live Connection from SAC to HANA
3. Dataset with Latitude and Longitude
4. WebIDE Calculation Views
1. hdinamespace subfolder Setting
2. Create SAP_BOC_SPATIAL folder
3. Spatial Reference 3857
4. Location Data
5. Create Geo Dimensional Calculation View with ST_POINT
6. Associate Calc Views in SAP Analytics Cloud Model
For the SAC Location Dimension to be picked up in your model, you need the WebIDE hdinamespace setting as below
Pre-requisites
1. HANA Cloud / HANA On-Prem with XSA
2. Live Connection from SAC to HANA
3. Dataset with Latitude and Longitude
4. WebIDE Calculation Views
Required Steps
1. hdinamespace subfolder Setting
2. Create SAP_BOC_SPATIAL folder
3. Spatial Reference 3857
4. Location Data
5. Create Geo Dimensional Calculation View with ST_POINT
6. Associate Calc Views in SAP Analytics Cloud Model
1. hdinamespace subfolder Setting
For the SAC Location Dimension to be picked up in your model, you need the WebIDE hdinamespace setting as below
Figure 1: db/src/.hdinamespace
"subfolder": "append"
Warning, if you change an existing project using “ignore” then some re-work will be required.
2. Create SAP_BOC_SPATIAL folder
SAP Analytics Cloud looks for location data inside the sub folder SAP_BOC_SPATIAL.
This should be created inside the WebIDE project src folder.
Figure 2: SAP_BOC_SPATIAL folder
3. Spatial Reference 3857
For SAC to visualise the location data, HANA must have the Spatial Reference 3857 available.
We can check this with the public synonym ST_SPATIAL_REFERENCE_SYSTEMS.
Figure 3: ST_SPATIAL_REFERENCE_SYSTEMS – 3857
If you do NOT see the SRS_ID 3857 then you can execute the SQL below to add that
CREATE SPATIAL REFERENCE SYSTEM "WGS 84 / Pseudo-Mercator" IDENTIFIED BY 3857 TYPE PLANAR
SNAP TO GRID 1e-4
TOLERANCE 1e-4
COORDINATE X BETWEEN -20037508.3427892447 AND 20037508.3427892447 COORDINATE Y BETWEEN -19929191.7668547928 AND 19929191.766854766 ORGANIZATION "EPSG" IDENTIFIED BY 3857
LINEAR UNIT OF MEASURE "metre"
ANGULAR UNIT OF MEASURE NULL POLYGON FORMAT 'EvenOdd'
STORAGE FORMAT 'Internal'
DEFINITION 'PROJCS["Popular Visualisation CRS / Mercator",GEOGCS["Popular Visualisation CRS",DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137,0,AUTHORITY["EPSG","7059"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[ "EPSG","6055"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree", 0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4055"]],UNIT[ "metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["cen tral_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PA RAMETER["false_northing",0],AUTHORITY["EPSG","3785"],AXIS["X",EAST],AXIS["Y", NORTH]]'
TRANSFORM DEFINITION '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null
+wktext +no_defs'
4. Location Data
The location dataset must not contain duplicate values. To perform the correct join SAC requires a unique list of locations to ensure referential integrity of your model. This dataset will need latitude, longitude data and a field that joins to other Calc Views.
Here I have the table of UK Local Authorities, LAD2019_WKT, sorted on the field lad19cd, which I can see is unique.
Figure 4: Location Dataset
5. Create Geo Dimensional Calculation View with ST_POINT
We can now create a new dimensional Calculation View inside the SAP_BOC_SPATIAL folder.
Figure 5: New Dimensional Calc View, notice the Namespace: SAP_BOC_SPATIAL
The output column names need to be unique across the two calculation views that you are using with SAC. I therefore appended _geo to the end of the lad19cd and lad19nm.
Figure 6: Location Dimensional Calculation View
Create Calculated Column of data type ST_POINT.
Using the fields “long” and “lat” we generate the ST_POINT column that SAP Analytics Cloud requires using the SRS 3857.
ST_Transform(ST_GeomFromText('POINT(' || "long" || ' ' || "lat" || ')', 4326),3857)
Figure 7: Calculated Column, LOCAL_AUTHORITY_GEO ST_POINT
We can Save and Build the Calculation View.
Figure 8: Build Calculation View
We should data preview it to verify it works as expected. Note how the name is prefixed with SAP_BOC_SPATIAL (the subfolder we created in step 2.)
Figure 9: Data Preview of Local Authority Calc View
6. Associate Calc Views in SAP Analytics Cloud Model
Open an existing SAC Model that will join to the fields exposed in the above model, in my case I can join on either lad19cd_geo or lad19nm_geo. Click the “Location Dimension” button.
Figure 10: Open Existing SAC HANA Model
We need to associate our Geo Dimensional Calc View with an existing calculation view.
Figure 11: Create Location Dimension
The final test is to create a Geo Map using this model to verify both the data and locations are displayed correctly on the map.
Figure 11: SAP Analytics Cloud Geo Map
No comments:
Post a Comment