Snowflake for DevelopersGuidesDeploy Route Optimization Demo with Cortex Code

Deploy Route Optimization Demo with Cortex Code

Cortex LLM
Becky O'Connor, Piotr Paczewski, Oleksii Bielov

🚚 Simulate. Optimize. Deliver. Build an interactive route optimization demo using real-world business locations - powered by OpenRouteService in Snowflake.

Overview

Route Optimization Simulator

Build a fully interactive Route Optimization Simulator using the OpenRouteService Native App.

This quickstart deploys a demo application that simulates vehicle routing scenarios using real-world business locations from the Carto Overture Maps dataset. You'll explore routing functions through an interactive notebook and run a complete Streamlit simulator.

What You'll Build

🚚 Route Optimization Simulator - A fully interactive Streamlit app that:

  • Finds potential distributors and customers using AI-powered location search
  • Generates catchment areas using isochrones
  • Optimizes routes for multiple vehicles with different skills and time windows
  • Visualizes routes, delivery points, and vehicle assignments on interactive maps

📓 AISQL Exploration Notebook - Learn how to:

  • Use AI to generate realistic sample data for your region
  • Call the Directions, Optimization, and Isochrones functions
  • Visualize routes and catchment areas with Pydeck

Prerequisites

IMPORTANT: This demo requires the OpenRouteService Native App to be installed and running. If you haven't installed it yet, complete the Install OpenRouteService Native App quickstart first.

Required:

  • OpenRouteService Native App deployed and activated
  • Cortex Code CLI installed and configured
  • Active Snowflake connection with ACCOUNTADMIN access

What You'll Learn

  • Deploy demo notebooks and Streamlit apps using Cortex Code skills
  • Work with the Carto Overture Maps Places dataset for real-world POI data
  • Use AISQL functions to generate sample data with Snowflake Cortex
  • Build multi-layer geospatial visualizations with Pydeck
  • Create vehicle routing simulations with time windows, capacity, and skills

Deploy the Demo

Use Cortex Code to deploy the demo including Marketplace data, notebooks, and the Streamlit simulator.

Run the Deploy Demo Skill

In the Cortex Code CLI, type:

use the local skill from oss-deploy-route-optimization-demo/skills/deploy-demo

NOTE: The skill will first verify that the OpenRouteService Native App is installed. If it's not found, it will provide instructions to install it first.

Checks Installed

Cortex Code verifies that the Native App is installed and all four services are running before proceeding with the demo deployment.

The skill then uses interactive prompting to gather required information:

Interactive Prompts

TIP: Use your keyboard arrow keys to navigate through options, then press Enter to confirm your selection.

Cortex Code will automatically:

  • Verify OpenRouteService Native App is installed and running
  • Acquire Marketplace Data - Gets the Carto Overture Maps Places dataset with 50+ million POIs worldwide
  • Create Demo Database - Sets up VEHICLE_ROUTING_SIMULATOR with required schemas
  • Deploy Notebooks - Provisions the AISQL notebook customized for your chosen city
  • Deploy Simulator - Creates the Route Optimization Streamlit app with real POI data

What Gets Installed

The demo skill creates the following Snowflake objects:

Marketplace Data

ComponentNameDescription
DatabaseOVERTURE_MAPS__PLACESCarto Overture Maps Places dataset with 50M+ POIs worldwide

Demo Database & Infrastructure

ComponentNameDescription
DatabaseVEHICLE_ROUTING_SIMULATORMain demo database
SchemaVEHICLE_ROUTING_SIMULATOR.DATAPrepared POI data for the simulator
SchemaVEHICLE_ROUTING_SIMULATOR.NOTEBOOKSNotebook storage and stages
SchemaVEHICLE_ROUTING_SIMULATOR.STREAMLITSStreamlit app storage
WarehouseROUTING_ANALYTICSCompute warehouse for queries (auto-suspend 60s)
StageNOTEBOOKS.notebookStage for notebook files
StageSTREAMLITS.STREAMLITStage for Streamlit files

Notebooks

ComponentNameDescription
NotebookNOTEBOOKS.ADD_CARTO_DATAPrepares POI data from Carto Overture for the demo
NotebookNOTEBOOKS.ROUTING_FUNCTIONS_AISQLInteractive exploration of Directions, Optimization, and Isochrones

Streamlit Application

ComponentNameDescription
StreamlitSTREAMLITS.SIMULATORRoute Optimization Simulator with real POI data

Once deployment completes successfully, you'll see a summary with direct links to your resources:

Demo Deployed Successfully

Cortex Code confirms all demo components are installed and ready to use:

Demo Installed

Explore the Routing Functions with AISQL

The AISQL notebook is an interactive exploration of all three routing functions. It uses Snowflake Cortex AI to generate realistic sample data - restaurants, delivery jobs, customer addresses - all customized for your configured region.

  1. Navigate to Projects > Notebooks in Snowsight
  2. Open ROUTING_FUNCTIONS_AISQL

What the Notebook Covers:

SectionWhat You'll Learn
1. Simple DirectionsGenerate a hotel and restaurant using AI, then call the DIRECTIONS function to get point-to-point routing
2. Cortex Generated MapsLet AI write the Pydeck visualization code for you
3. Advanced Directions with WaypointsCreate a multi-stop route visiting multiple locations
4. Route Optimization (1 Vehicle)Use the OPTIMIZATION function to assign jobs efficiently
5. Route Optimization (Multiple Vehicles)Scale up with 40 customers and 5 vehicles with different skills
6. IsochronesGenerate catchment polygons showing reachable areas

Run the Streamlit Simulator

Streamlit Simulator

Navigate to the Simulator Streamlit app:

  1. Go to Projects > Streamlits in Snowsight
  2. Click on SIMULATOR

Setting the Context

Open the sidebar to configure:

  • Industry Type - Food, Health, or Cosmetics
  • LLM Model - For location search (recommend mistral-large2)
  • Search Location - Free text like "Fisherman's Wharf" or "Golden Gate Bridge"
  • Distance Radius - How far to search for distributors
Sidebar Menu

Select a Distributor

Distributor Selection

Choose from the list of nearby distributors sorted by distance from your search location.

Configure Vehicles

Vehicle Configuration

Configure up to 3 vehicles with:

  • Time Windows - Start and end hours
  • Vehicle Profile - Car, HGV, or bicycle
  • Skills - Each vehicle has a pre-assigned skill level

Generate Catchment Area

Isochrone Catchment

Set the order acceptance catchment time to generate an isochrone showing all reachable delivery locations.

View Optimized Routes

Job Assignments

See which jobs are assigned to which vehicles based on skills and time windows.

Route Map

View the optimized routes on an interactive map with color-coded paths for each vehicle.

Vehicle Itinerary

Vehicle Itinerary

Each vehicle tab shows detailed turn-by-turn instructions for the entire journey.

Customize the Demo

You can customize the demo for different industries or regions using the customization skills:

Change Industries

Simply type a natural language command like:

change industry

Cortex Code automatically finds the relevant skill and guides you through the options:

Change Industry

You can add a new industry, modify an existing one, or replace one with something different. The skill updates the Streamlit simulator with your customized industry categories (product types, customer types, vehicle skills).

Once the wizard completes, the Streamlit app is automatically refreshed with your new industry:

Change Industry Result

Alternatively, you can use the full skill path:

use the local skill from oss-deploy-route-optimization-demo/skills/customizations/industries

Update Streamlit Apps

use the local skill from oss-deploy-route-optimization-demo/skills/customizations/streamlits

Update the Simulator with region-specific coordinates.

Update Notebooks

use the local skill from oss-deploy-route-optimization-demo/skills/customizations/aisql-notebook
use the local skill from oss-deploy-route-optimization-demo/skills/customizations/carto-notebook

Update the notebooks with city-specific AI prompts and POI data filters.

NOTE: To change the map region (e.g., San Francisco to Paris), you need to update the OpenRouteService Native App first. See the Install OpenRouteService Native App quickstart for location customization.

Uninstall the Demo

Cortex Code makes uninstallation simple with natural language commands.

Uninstall Demo Only

To remove just the demo resources (notebooks, Streamlit simulator) while keeping the OpenRouteService Native App:

uninstall demo

This will:

  • Remove the demo database (VEHICLE_ROUTING_SIMULATOR) including notebooks and Streamlit apps
  • Optionally remove the Carto Overture Maps marketplace data (OVERTURE_MAPS__PLACES)
  • Optionally remove the warehouse (ROUTING_ANALYTICS)
Demo Uninstalled

NOTE: The OpenRouteService Native App remains installed and functional. You can redeploy the demo at any time.

Uninstall Everything

To remove both the demo AND the OpenRouteService Native App:

uninstall demo and optimizer

Cortex Code will run both uninstall skills in sequence, removing all resources from your Snowflake account.

Uninstall Complete

TIP: You can also use the full skill paths if preferred:

  • use the local skill from oss-deploy-route-optimization-demo/skills/uninstall-demo
  • use the local skill from oss-install-openrouteservice-native-app/skills/uninstall-route-optimizer

Available Cortex Code Skills

For reference, here are the Cortex Code skills for the Route Optimization Demo:

Demo Skills

SkillDescriptionCommand
check-ors-prerequisiteVerify ORS Native App is installeduse the local skill from oss-deploy-route-optimization-demo/skills/check-ors-prerequisite
deploy-demoDeploy notebooks and Simulator Streamlituse the local skill from oss-deploy-route-optimization-demo/skills/deploy-demo
uninstall-demoRemove demo database, optionally marketplace datause the local skill from oss-deploy-route-optimization-demo/skills/uninstall-demo

Customization Sub-Skills

Sub-SkillDescriptionCommand
industriesCustomize industry categoriesuse the local skill from oss-deploy-route-optimization-demo/skills/customizations/industries
streamlitsUpdate Simulator with region coordinatesuse the local skill from oss-deploy-route-optimization-demo/skills/customizations/streamlits
aisql-notebookUpdate AI prompts for your regionuse the local skill from oss-deploy-route-optimization-demo/skills/customizations/aisql-notebook
carto-notebookUpdate POI data sourceuse the local skill from oss-deploy-route-optimization-demo/skills/customizations/carto-notebook

ORS Skills

For OpenRouteService Native App skills (installation, location/vehicle customization, uninstall), see the Install OpenRouteService Native App quickstart.

Conclusion and Resources

Conclusion

You've deployed a complete Route Optimization Simulator that demonstrates the power of combining:

  • OpenRouteService Native App - Self-contained routing engine in Snowflake
  • Carto Overture Maps - Real-world points of interest for authentic simulations
  • Snowflake Cortex AI - Generate sample data with natural language
  • Streamlit - Interactive visualization that brings routing scenarios to life

What You Learned

  • Deploy demo applications using Cortex Code skills
  • Work with the Carto Overture Places dataset for POI data
  • Use AISQL to generate sample data with Snowflake Cortex
  • Build vehicle routing simulations with time windows, capacity, and skills
  • Visualize routes and catchment areas with Pydeck

Related Quickstart

Source Code

OpenRouteService Resources

Cortex Code & Snowflake

Updated 2026-01-22

This content is provided as is, and is not maintained on an ongoing basis. It may be out of date with current Snowflake instances