For a third-get together logistics company like RWI Logistics, geographic data can be a critical device for resolving challenges and generating remedies for our shoppers. We often need to seem up no matter whether we have managed any truckloads into or out of a listing of geographic parts, but it can be challenging to quickly match spots if they have a different town, point out, and postal code from 1 an additional.
For example, if we desired to know how numerous loads we’ve sent in the vicinity of Fort Thomas, Kentucky, the easiest answer would be to research for past transactions with “City” = ‘Fort Thomas’ and “State” = ‘KY’. However this technique would not return transactions for Cincinnati, Ohio regardless of the truth that Cincinnati is only 5 miles from Fort Thomas, since the town and condition don’t match our unique research requirements.
Domo has enabled us to apply an efficient and repeatable resolution to this difficulty. Our system utilizes Redshift dataflows and the Domo Dimensions Connector to match locations in just a specified mileage radius, rather than relying on drawn boundaries like state strains.
There are 3 datasets expected for this process:
- Place record – A postal code checklist for desired locations, these kinds of as likely new consumer shipping and delivery locations
- Transaction record – A listing of earlier destinations to look for, that contains postal codes
- Domo Proportions Connector “cityzip.csv” report – We will use this dataset to search up the latitude and longitude of each individual location
Phase 1 – Aggregate latitude/longitude table
Some postal codes appear in the Domo Proportions dataset a number of situations, so we ought to use a desk remodel in Redshift to aggregate this table so there is one particular row per postal code to stay clear of duplicating rows when we sign up for to the other tables.
pick "Postal", avg("Latitude") as "Lat", avg("Longitude") as "Lengthy" from "metropolis_zip" group by "Postal"
Action 2 – Completely transform destinations into points on the globe
We first require to come across the coordinates of the postal codes in the locale listing and transaction heritage by signing up for equally datasets to the aggregated latitude/longitude table by postal code. The st_level() purpose transforms the latitude and longitude of each and every postal code into a place on the globe. Note that functioning SQL previews will not screen any details when these details are incorporated in the question.
Stage 3 – Be part of datasets
Now that the place record and transaction historical past the two include details, we can use the st_DistanceSphere() functionality to compute the length (meters) among points. We use this length as the criteria for the be part of involving the two tables. In this instance, we match places and transactions that are inside of 100 miles of every other.
b."locale identify" as "transaction area name"
from "location_coord" as a
left sign up for "heritage_coord" as b
on st_distancesphere(a."coord",b."coord") <= 1609.34*100
Step 4 – Visualize results
Using the above transform as the output of the Redshift dataflow, we then create a summary card that displays the count of historical transactions by location name. We can also gather more context by drilling to the transaction detail.
Since implementing this process, RWI Logistics has improved the efficiency and consistency of location-matching tasks. Domo has given us the ability to quickly analyze location data for various use cases and share insights across the organization.