Created
October 4, 2017 14:48
-
-
Save ramiroaznar/c461a399eb20ae7392ff77badfea3ce2 to your computer and use it in GitHub Desktop.
Routing with CARTO functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
origin as ( | |
SELECT cartodb_id, name, the_geom FROM populated_places WHERE name ilike 'madrid' | |
), | |
destiny as ( | |
SELECT cartodb_id, name, the_geom FROM populated_places WHERE adm0name ilike 'spain' | |
) | |
SELECT destiny.cartodb_id, origin.name || '-' || destiny.name as route, r.shape as the_geom, r.length, r.duration/60 as minutes | |
FROM origin, destiny, cdb_route_point_to_point(origin.the_geom, destiny.the_geom, 'car') r | |
WHERE origin.cartodb_id <> destiny.cartodb_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment