Knowage Location Intelligence tools allows the definition of Geo-referenced documents. In this new AIKnow.info Blog article, we will see how to create a cartographic document in Knowage representing the distribution of population by regions. This will be done loading a layer of Italian regions and joining each cartographic element with the information of population coming from a specific dataset. The result will be a map showing Italian regions with different colors based on population (Fig.1).
Clearly the procedure illustrated in this simple example can be applied to more complex cases, regarding to cartographic or data side.
First of all we will create the cartographic layer in GeoJSON, one of the format in use by Knowage.
Since most common cartographic content comes in SHP Format, and also the one related to Italian Regions borders (that can be downloaded from https://www.istat.it/it/archivio/124086 see Fig.2), it’s necessary to convert the SHP in GeoJSON giving the correct coordinate system.
Fig.2 Source of Italian Regions borders layer
We will do that using GeoServer (http://geoserver.org/) an open source server to manage cartographic content. If you want to install GeoServer on the local machine where Knowage is installed too, take care to select for Geoserver a different port from the Knowage one; in fact the default port for both software is 8080.
You can find the procedure to publish a layer in SHP format with GeoServer at this link: http://docs.geoserver.org/stable/en/user/gettingstarted/shapefile-quickstart/
In short you have to:
- move the shape into <GEOSERVER_DATA_DIR>/data folder, where <GEOSERVER_DATA_DIR> is the root of the GeoServer data directory (if no changes have been made to the GeoServer file structure, the path is geoserver/data_dir/data/);
- Create a new workspace
- Navigate to Data – Workspaces and click on Add New workspace button;
- Enter the workspace name and namespace URI (the URI does not need to resolve to an actual valid web address);
- Click on Submit button;
- Create a new store
- Navigate to Data – Stores;
- Click the Add new Store button;
- Between the available formats, choose Shapefile, this will display the New Vector Data Source page;
- Begin configuring the Basic Store Info:
- Select the workspace previously created;
- Enter the Data Source Name and a brief description;
- Under Connection parameters browse to the location URL of the shapefile;
- Clicking Save button will redirect to the New Layer page;
- Create a layer
- On the New Layer page click Publish beside the layer name;
- The Edit Layer page defines the data and publishing parameters for a layer. Enter a short Title and an Abstract;
- At this point it’s fundamental to define the Coordinate Reference System used by Knowage. To do that you have to set Declared SRS to EPSG:4326 and SRS handling to Reproject native to declared
Fig.3 Coordinate Reference Systems definition
- Generate the layer’s bounding boxes by clicking the Compute from data and then Compute from native bounds links;
- Click the Publishing tab at the top of the page;
- Under WMS Settings, ensure that the Default Style is set to line;
- Finalize the layer configuration by scrolling to the bottom of the page and click Save.
- Preview the layer
- Navigate to the Layer Preview screen and find the layer just created;
- Click the OpenLayers link in the Common Formats column;
- An OpenLayers map will load in a new tab and will display the shapefile data with the default line style. You can use this preview map to zoom and pan around the dataset, as well as display the attributes of features (Fig.4).
Fig.4 OpenLayer map preview
Note that every cartographic element has two attribute COD_REG and REGIONE, that we will use in the following to join with the other information from the dataset.
To obtain the GeoJSON file come back to Data – Layer Preview Menu, and under All Formats combo box select GeoJSON format (Fig.5)
Now logging to Knowage as an administrator it’s possible to define the Layer Catalog. Clicking on Catalogs – Layer Catalogs the interface in Fig. 6 will be showed. Specify a Label and a Name, choose File as Layer Type and select the GeoJSON already created.
Complete the other information required: Layer label, Layer name, Layer ID and Layer order (select 1 as a value).
Finally select the role that can access the resource (/demo/admin and /demo/user in this example).
To go forward we need a data source with the information to join to cartographic content. For this purpose it’s possible to follow the method illustrated in the first blog post http://www.aiknow.info/2017/10/24/knowage/.
In this case starting from a table with population data for every Italian regions (Fig.7), we will generate a dataset of Flat type (Fig.8)
With Layer data and Data Set ready to use, it’s now possible to generate a Geo-referenced analysis document.
This can be done logging to Knowage as a user and chosing My workspace icon, and then Analysis folder.
Clicking on Add icon will show GIS Document designer. First you have to select the dataset (that for this example is POP_REG, see Fig.9).
Then you have to select a layer from the list of the available ones, for this example we defined a layer called itareg (Fig.5 and Fig.10)
Then you can add one or more join columns, by choosing the matching column from the dataset and the layer (Fig.11).
Then it’s possible to add an indicator and a filter defining a measure and a label for that. Finally check the Map menu configuration item you want to allow (Fig.12).
Clicking on save button, the template will be saved and you can have a preview of the Cartographic document clicking on Edit Map (Fig.13). Using menu on the right of the page it’s possible to use tools to interact with the map, layers, and to define configurations.
Fig. 13 Location intelligence document