Extracting Latitude and Longitude from an Array column
When your data stores latitude and longitude coordinates in an array format within a column, you can use Akuko to extract and create separate dimensions for Latitude and Longitude. This guide will walk you through the process step by step.
Prerequisites
Before you start, ensure you have:
- Access to Akuko: You should have an active Akuko account with the necessary permissions to create or modify Dimensions within a Source.
Step 1: Access Your Source
Log in to your Akuko account.
From the Akuko dashboard, navigate to the "Sources" section.
Select the Source where your data with the array column resides.
Step 2: Cast Array column to string
In the Source settings, navigate to the "Dimensions" section.
Locate the dimension that is stored as an array in the database.
In the calculation or formula section, cast the column to a string using:
ST_AsText(your_array_column)
Step 3: Create Separate Latitude and Longitude Dimensions
In the Source settings, navigate to the "Dimensions" section.
Click on the "Add Dimension" or "Create Dimension" button to initiate the creation process.
Create a new dimension for Latitude. Give it a meaningful name like "Latitude."
For the data type, select the appropriate type for your latitude values, often "Number" or "Decimal."
In the calculation or formula section, write an expression to extract the Latitude from the array column. If your data is stored as an array like
[lng, lat]
, you can use SQL functions to extract the Latitude. For example:SUBSTRING_INDEX(SUBSTRING_INDEX(array_column_name, ',', -1), ']', 1)
Click "Save" or "Create" to save your new Latitude dimension.
Repeat the process to create a new dimension for Longitude. Name it something like "Longitude."
For the data type, select the appropriate type for your longitude values, often "Number" or "Decimal."
In the calculation or formula section, write an expression to extract the Longitude from the array column. For example:
SUBSTRING_INDEX(SUBSTRING_INDEX(array_column_name, ',', 1), '[', -1)
Click "Save" or "Create" to save your new Longitude dimension.
Step 4: Utilize Your Latitude and Longitude Dimensions
Your separate Latitude and Longitude dimensions are now available for use within your Source.
You can use these dimensions in various components, including Map components, to visualize geographical data effectively.
Conclusion
Extracting Latitude and Longitude from an array column within your Source allows you to work seamlessly with geographical data in Akuko. These separate dimensions empower you to build interactive maps, perform spatial analysis, and create engaging data stories that incorporate location-based insights.
Explore the possibilities of your newly created Latitude and Longitude dimensions to unlock the full potential of your geographical data within Akuko.