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).
This function consumes isolines quota. Each call consumes as many units of quota as the number of rows your input table or query has. Before running, we recommend checking the size of the data to be geocoded and your available quota using the LDS_QUOTA_INFO() function.
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 Redshift console or client of choice after connecting your Redshift project with your CARTO account. To check whether your Redshift account or Service Account has access to the LDS module, please execute this query:
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.
'select * from carto_dev_data.demo_tables.starbucks_ny_geocode',
'walk', 900, 'time'
In the query we specify the output table in CREATE TABLE and next, in the SELECT, we call the ISOLINE() specifying “geom_tomtom” 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 “_iso_geom” column with the geometry of the polygon of the isoline that we have calculated.
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 Redshift.
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.