How to Extract Latitude and Longitude from Google Address Field in Origami API
When working with the Origami API, you may encounter a situation where the Google Address field, which should provide an object with latitude and longitude, is instead returning as a string. This article will guide you on how to extract the latitude and longitude values from this string in Bold BI.
Splitting the String
To separate the latitude and longitude values, you can use the following expression:
split_part([Column_name], 'splitter' , Index of value)
For instance, if the latitude and longitude values on the address field are 20.593683,78.962883
, you can use the following expressions:
split_part([Address], ',' ,1) – latitude expression
split_part([Address], ',' ,2) – longitude expression
Note: The split_part function is supported in several data sources in Bold BI, including:
-
PostgreSQL: This function is used to split a string into multiple parts based on a delimiter.
-
MySQL: Although not directly supported, similar functionality can be achieved using the SUBSTRING_INDEX function.
-
SQL Server: Similar functionality can be achieved using the STRING_SPLIT function.
Configuring Expression Fields
To configure the expression fields in the data source, you can refer to the following documentation: Configuring Expression Fields | Bold BI Embedded Docs
This will guide you through the process of transforming data and configuring expression columns in Bold BI.
Conclusion
Extracting latitude and longitude values from a Google Address field in Origami API can be achieved by splitting the string and configuring the expression fields. This allows you to work with these values separately and utilize them as needed in your data analysis.