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 (__iso_geom column).
Create isolines from the BigQuery 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 BigQuery console or client of choice after connecting your BigQuery project with your CARTO account. To check whether your Google 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 that can be found in the publicly available
bqcartodemos.sample_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 (in this order) the input table, the output table and “geom” as column name for the origin geometry column. We add that we want to calculate the isolines based on 15 minutes walking, fixing “mode” parameter on “walk” and “range_value” parameter on 900 seconds (15 min). Also you need to provide us the API base url where your account is stored in “api_base_url” and your token for accessing the different API services in “lds_token” parameter.
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 “_iso_geom” 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 BigQuery.
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.