Generating trade areas based on drive/walk-time isolines
In this example, we will create isolines around some Starbucks locations in order to estimate their trade areas based on drive-time areas around them.
This process will generate a new table with the columns of the input table (except the column with the point geometry) plus a new column with the isoline polygon (geom column).
Create isolines from the Snowflake console
As a module within CARTO’s Analytics Toolbox, the location data services (lds) capabilities are available as SQL procedures that can be executed directly from your Snowflake console or client of choice after connecting your Snowflake project with your CARTO account. To check whether your Snowflake account or Service Account has access to the LDS module, please execute this query:
The lds module is generally available in the Analytics Toolbox since the “July 26, 2022” version. Please check the Getting Access section if you run into any errors when running the query above.
For this example we will use a table with the Starbucks addresses geocoded
CARTO_DEV_DATA.DEMO_TABLES.STARBUCKS_NY_GEOCODE . The table contains information about Starbucks stores and a column called “geom” with the geographic coordinates (latitude and longitude) of each location. Around these locations we will create isolines based on 15 minutes walking.
In order to create the isolines, we will execute the CREATE_ISOLINES() procedure with the following SQL query:
In the query we specify the output table in CREATE TABLE and next, in the SELECT, we call the ISOLINE() specifying “GEOM” as column name for the origin geometry column, “mode” parameter on “walk” and “range_value” parameter to 900 seconds (15 min) in order to calculate the isolines based on 15 minutes walking. Last but not least, we need to use FROM call to specify the input table for the geocoding.
As a result of the query we obtain a new table with the name that we have chosen in the second parameter of the procedure. This output table has the same schema as the input one, but adding the “GEOM_ISOLINE” column with the geometry of the polygon of the isoline that we have calculated.
Create isolines from CARTO Builder
If you prefer you can create isolines without writing any line of SQL code thanks to our map-making tool CARTO Builder, which offers a user interface that you can use to calculate trade areas based on walk/drive times or distances. Let’s use it here to reproduce the same-use case as we have previously done from the SQL console, but from the Builder interface.
First of all, you should create a new map and add a source with the table including the locations around which you want to calculate isolines. You can find more details on how to create maps in Builder in the Maps section of the User Manual.
Then, on that data source, click on “Add SQL Analysis”.
Select “Trade areas” in the list of available SQL Analysis.
Choose the parameters of your isolines, in this example “walk” mode and 900 seconds (15 minutes) . Then, click on the “Save results in a new table” button.
You should choose the location and the name of the output table and click on “create table” to run the process. As simple as that, directly from CARTO Builder and running natively in Snowflake.
As a result of the analysis, we obtain a new table (also added as a data source in our map) with the name that we have chosen in the last step which contains the geometry of the polygons of the isoline that we have calculated. Now we have two layers in our map, the original data with the Starbucks locations and a second layer with the isolines that we have created around each store.
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 960401.