Wednesday, 17 February 2021

Importing shapefiles into SAP HANA Cloud using the Wizard

In this blog post I will try and show you the easiest way to import shapefiles data into HANA Cloud, via the wizard.

There are alternative ways of importing spatial data, that can be used.

◉ Import shapefile via wizard

◉ Import CSV via wizard and convert to spatial data types

◉ Import CSV from Cloud Object Store (S3, GCS, ADL) and convert.

For clarification, spatial data means geometries, shapes such as polygons that will be stored as spatial data types.

Prepare the Data

To use the shapefiles import wizard, your spatial data needs to be using one of the supported spatial references. HANA supports 1000s of spatial references, currently the wizard only supports 5.

The wizard supports the following spatial references IDs (SR IDs)

◉ Default

◉ 4326

◉ 3857

◉ 1000004326

◉ 2147483646

The wizard expects a .tar.gz file containing both the .shp and .dbf file of the the same name.

The file I’m using is the English geographic regions from UK Office National Statistics (ONS).

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 1.1 Download Shapefile

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 1.2: Feature layer metadata

Viewing the associated metadata of this file shows that the spatial reference is 27700, which is not one of the supported ones for the wizard.

We can open the shapefile with QGIS to convert this to a supported spatial.

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 1.3: QGIS – Save Feature As

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 1.4: Save Vector Layer as Options

Create a .tar.gz containing the .shp and .dbf to upload.

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 1.5: Create .tar.gz

Database Explorer


The easiest way to import a shapefile is using the Database Explorer, via Import Data

Right Click and select Import Data, open the wizard.  We can use that with an appropriate .tar.gz and follow the steps.

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.1: Import Data

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.2: Import Type, ESRI Shapefiles

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.3: Select file, must be .tar.gz containing .shp and .dbf

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.4: Import Target Schema, table name will be the original filename without extensions

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.5: Specify Spatial Reference (SRID)

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.6: Import Complete

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.7: Check Table

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.8: Database Explorer Data Preview, SHAPE column not so readable here

SAP HANA Cloud, SAP HANA Tutorial and Material, SAP HANA Certification, SAP HANA Learning, SAP HANA Guides, SAP HANA Career, SAP HANA Preparation
Figure 2.9: DBeaver, much better to validate spatial data

No comments:

Post a Comment