diff --git a/high_quality_transit_areas/bus_corridors.ipynb b/high_quality_transit_areas/bus_corridors.ipynb index c060d0d90..54fa13b8d 100644 --- a/high_quality_transit_areas/bus_corridors.ipynb +++ b/high_quality_transit_areas/bus_corridors.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 18, "id": "d7bcdd2a-75f6-429b-8c2e-10263abf7ace", "metadata": { "collapsed": true, @@ -17,71 +17,74 @@ "output_type": "stream", "text": [ "Requirement already satisfied: geopandas in /opt/conda/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (0.10.2)\n", - "Requirement already satisfied: pygeos in /opt/conda/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (0.11.1)\n", - "Requirement already satisfied: ipyleaflet in /opt/conda/lib/python3.9/site-packages (from -r requirements.txt (line 3)) (0.14.0)\n", - "Requirement already satisfied: fiona>=1.8 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (1.8.20)\n", - "Requirement already satisfied: pyproj>=2.2.0 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (3.2.1)\n", + "Requirement already satisfied: pygeos in /opt/conda/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (0.12.0)\n", + "Requirement already satisfied: ipyleaflet in /opt/conda/lib/python3.9/site-packages (from -r requirements.txt (line 3)) (0.15.0)\n", "Requirement already satisfied: pandas>=0.25.0 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (1.3.4)\n", "Requirement already satisfied: shapely>=1.6 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (1.8.0)\n", + "Requirement already satisfied: pyproj>=2.2.0 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (3.3.0)\n", + "Requirement already satisfied: fiona>=1.8 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (1.8.20)\n", "Requirement already satisfied: numpy>=1.13 in /opt/conda/lib/python3.9/site-packages (from pygeos->-r requirements.txt (line 2)) (1.20.3)\n", - "Requirement already satisfied: traittypes<3,>=0.2.1 in /opt/conda/lib/python3.9/site-packages (from ipyleaflet->-r requirements.txt (line 3)) (0.2.1)\n", + "Requirement already satisfied: xyzservices>=2021.8.1 in /opt/conda/lib/python3.9/site-packages (from ipyleaflet->-r requirements.txt (line 3)) (2021.11.0)\n", "Requirement already satisfied: ipywidgets<8,>=7.6.0 in /opt/conda/lib/python3.9/site-packages (from ipyleaflet->-r requirements.txt (line 3)) (7.6.5)\n", + "Requirement already satisfied: traittypes<3,>=0.2.1 in /opt/conda/lib/python3.9/site-packages (from ipyleaflet->-r requirements.txt (line 3)) (0.2.1)\n", + "Requirement already satisfied: munch in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (2.5.0)\n", "Requirement already satisfied: click-plugins>=1.0 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (1.1.1)\n", - "Requirement already satisfied: click>=4.0 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (8.0.3)\n", - "Requirement already satisfied: setuptools in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (58.3.0)\n", + "Requirement already satisfied: attrs>=17 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (21.2.0)\n", "Requirement already satisfied: certifi in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (2021.10.8)\n", + "Requirement already satisfied: setuptools in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (59.1.1)\n", "Requirement already satisfied: six>=1.7 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (1.16.0)\n", - "Requirement already satisfied: attrs>=17 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (21.2.0)\n", "Requirement already satisfied: cligj>=0.5 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (0.7.2)\n", - "Requirement already satisfied: munch in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (2.5.0)\n", - "Requirement already satisfied: ipython>=4.0.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (7.29.0)\n", + "Requirement already satisfied: click>=4.0 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (8.0.3)\n", "Requirement already satisfied: jupyterlab-widgets>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.0.2)\n", - "Requirement already satisfied: traitlets>=4.3.1 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (5.1.1)\n", - "Requirement already satisfied: ipykernel>=4.5.1 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.4.2)\n", - "Requirement already satisfied: ipython-genutils~=0.2.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.2.0)\n", "Requirement already satisfied: widgetsnbextension~=3.5.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (3.5.2)\n", + "Requirement already satisfied: ipykernel>=4.5.1 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.5.0)\n", + "Requirement already satisfied: ipython-genutils~=0.2.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.2.0)\n", + "Requirement already satisfied: traitlets>=4.3.1 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (5.1.1)\n", "Requirement already satisfied: nbformat>=4.2.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (5.1.3)\n", + "Requirement already satisfied: ipython>=4.0.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (7.29.0)\n", "Requirement already satisfied: python-dateutil>=2.7.3 in /opt/conda/lib/python3.9/site-packages (from pandas>=0.25.0->geopandas->-r requirements.txt (line 1)) (2.8.2)\n", "Requirement already satisfied: pytz>=2017.3 in /opt/conda/lib/python3.9/site-packages (from pandas>=0.25.0->geopandas->-r requirements.txt (line 1)) (2021.3)\n", - "Requirement already satisfied: jupyter-client<8.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (7.0.6)\n", - "Requirement already satisfied: debugpy<2.0,>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.4.1)\n", "Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.1.3)\n", + "Requirement already satisfied: jupyter-client<8.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (7.0.6)\n", + "Requirement already satisfied: debugpy<2.0,>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.5.1)\n", "Requirement already satisfied: tornado<7.0,>=4.2 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.1)\n", - "Requirement already satisfied: pygments in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.10.0)\n", "Requirement already satisfied: jedi>=0.16 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.18.0)\n", - "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (3.0.21)\n", + "Requirement already satisfied: pygments in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.10.0)\n", + "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (3.0.22)\n", "Requirement already satisfied: pexpect>4.3 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.8.0)\n", "Requirement already satisfied: decorator in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (5.1.0)\n", "Requirement already satisfied: pickleshare in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.7.5)\n", "Requirement already satisfied: backcall in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.2.0)\n", - "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.1.2)\n", + "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.2.1)\n", + "Requirement already satisfied: jupyter-core in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.9.1)\n", + "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.2.1)\n", "Requirement already satisfied: jupyter-core in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.9.1)\n", "Requirement already satisfied: notebook>=4.4.1 in /opt/conda/lib/python3.9/site-packages (from widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.4.5)\n", "Requirement already satisfied: parso<0.9.0,>=0.8.0 in /opt/conda/lib/python3.9/site-packages (from jedi>=0.16->ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.8.2)\n", - "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /opt/conda/lib/python3.9/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.17.3)\n", + "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /opt/conda/lib/python3.9/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.18.0)\n", "Requirement already satisfied: pyzmq>=13 in /opt/conda/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (22.3.0)\n", - "Requirement already satisfied: nest-asyncio>=1.5 in /opt/conda/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.5.1)\n", "Requirement already satisfied: entrypoints in /opt/conda/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.3)\n", - "Requirement already satisfied: Send2Trash>=1.5.0 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.8.0)\n", - "Requirement already satisfied: terminado>=0.8.3 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.12.1)\n", - "Requirement already satisfied: nbconvert in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.2.0)\n", + "Requirement already satisfied: nest-asyncio>=1.5 in /opt/conda/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.5.1)\n", + "Requirement already satisfied: jinja2 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (3.0.3)\n", "Requirement already satisfied: prometheus-client in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.12.0)\n", - "Requirement already satisfied: jinja2 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (3.0.2)\n", + "Requirement already satisfied: Send2Trash>=1.5.0 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.8.0)\n", "Requirement already satisfied: argon2-cffi in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (21.1.0)\n", + "Requirement already satisfied: nbconvert in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.3.0)\n", + "Requirement already satisfied: terminado>=0.8.3 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.12.1)\n", "Requirement already satisfied: ptyprocess>=0.5 in /opt/conda/lib/python3.9/site-packages (from pexpect>4.3->ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.7.0)\n", "Requirement already satisfied: wcwidth in /opt/conda/lib/python3.9/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.2.5)\n", - "Requirement already satisfied: cffi>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.14.6)\n", + "Requirement already satisfied: cffi>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.15.0)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.9/site-packages (from jinja2->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.0.1)\n", - "Requirement already satisfied: defusedxml in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.7.1)\n", "Requirement already satisfied: testpath in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.5.0)\n", + "Requirement already satisfied: bleach in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.1.0)\n", + "Requirement already satisfied: mistune<2,>=0.8.1 in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.8.4)\n", "Requirement already satisfied: pandocfilters>=1.4.1 in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.5.0)\n", "Requirement already satisfied: jupyterlab-pygments in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.1.2)\n", - "Requirement already satisfied: mistune<2,>=0.8.1 in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.8.4)\n", - "Requirement already satisfied: bleach in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.1.0)\n", - "Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.5.4)\n", - "Requirement already satisfied: pycparser in /opt/conda/lib/python3.9/site-packages (from cffi>=1.0.0->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.20)\n", - "Requirement already satisfied: webencodings in /opt/conda/lib/python3.9/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.5.1)\n", + "Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.5.8)\n", + "Requirement already satisfied: defusedxml in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.7.1)\n", + "Requirement already satisfied: pycparser in /opt/conda/lib/python3.9/site-packages (from cffi>=1.0.0->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.21)\n", "Requirement already satisfied: packaging in /opt/conda/lib/python3.9/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (21.2)\n", + "Requirement already satisfied: webencodings in /opt/conda/lib/python3.9/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.5.1)\n", "Requirement already satisfied: pyparsing<3,>=2.0.2 in /opt/conda/lib/python3.9/site-packages (from packaging->bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.4.7)\n" ] } @@ -92,10 +95,19 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "id": "e37ce21c-ae28-4359-89b8-f628f852c489", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/opt/conda/lib/python3.9/site-packages/geopandas/_compat.py:111: UserWarning: The Shapely GEOS version (3.9.1-CAPI-1.14.2) is incompatible with the GEOS version PyGEOS was compiled with (3.10.1-CAPI-1.16.0). Conversions between both will be slow.\n", + " warnings.warn(\n" + ] + } + ], "source": [ "import calitp\n", "from calitp.tables import tbl\n", @@ -152,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "25b4b77d-3d2e-4ecc-a6db-fa27aecf71db", "metadata": {}, "outputs": [], @@ -164,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "ed58ef3a-f454-4f00-9202-bae1dc82f92d", "metadata": {}, "outputs": [], @@ -176,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "7d8165e1-492a-4013-bb1f-de1b252fa5d1", "metadata": {}, "outputs": [], @@ -201,7 +213,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "e3d9fa0d-35b0-4a9c-8e45-c5114e5c09a1", "metadata": {}, "outputs": [], @@ -231,7 +243,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "65c74fbd-059f-4df8-a3a1-e6c1361489b7", "metadata": {}, "outputs": [], @@ -249,33 +261,40 @@ " >> filter(_.calitp_itp_id == int(itp_id)) >> collect())\n", " wednesday = wednesday >> arrange(-_.service_date)\n", " wednesday = wednesday[wednesday['service_date'].apply(lambda x: x.weekday() == 2)]\n", - " wednesday = wednesday[wednesday['service_date'].apply(lambda x: x.month < 12)]\n", - " wednesday = wednesday[wednesday['service_date'] == wednesday['service_date'].iloc[0]] ## pick most recent Wednesday from Nov or earlier\n", + " wednesday = wednesday[wednesday['service_date'].apply(lambda x: x.month == 12)] ## December\n", + " wednesday = wednesday[wednesday['service_date'] == wednesday['service_date'].iloc[0]] ## pick most recent Wednesday from Dec or earlier\n", + " wednesday = wednesday >> select(_.calitp_itp_id, _.calitp_url_number, _.service_id)\n", " \n", " bus_routes = (tbl.gtfs_schedule.routes()\n", " >> filter(_.calitp_itp_id == int(itp_id))\n", - " >> filter(_.route_type.isin(['3', '11'])) ## bus and trolleybus\n", - " >> select(_.route_id) >> collect())\n", + " >> filter((_.route_type == '3') | (_.route_type == '11'))\n", + " >> select(_.calitp_itp_id, _.calitp_url_number, _.route_id) \n", + " # >> collect()\n", + " )\n", " print('loaded bus routes')\n", " \n", " if itp_id == 273:\n", " trips = (tbl.gtfs_schedule.trips()\n", " >> filter(_.calitp_itp_id == int(itp_id))\n", - " >> filter(_.service_id.isin(['1'])) ## temporary hardcode for SacRT\n", - " >> filter(_.route_id.isin(bus_routes.route_id))\n", + " >> filter(_.service_id == '1') ## temporary hardcode for SacRT\n", + " >> inner_join(_, bus_routes, on = ['calitp_itp_id', 'calitp_url_number', 'route_id'])\n", " >> collect())\n", " else:\n", " trips = (tbl.gtfs_schedule.trips()\n", " >> filter(_.calitp_itp_id == int(itp_id))\n", - " >> filter(_.service_id.isin(wednesday.service_id))\n", - " >> filter(_.route_id.isin(bus_routes.route_id))\n", - " >> collect())\n", + " >> inner_join(_, bus_routes, on = ['calitp_itp_id', 'calitp_url_number', 'route_id'])\n", + " >> collect()\n", + " >> inner_join(_, wednesday, on = ['calitp_itp_id', 'calitp_url_number', 'service_id'])\n", + " )\n", " print('loaded trips')\n", " stop_times = (tbl.gtfs_schedule.stop_times()\n", " >> filter(_.calitp_itp_id == int(itp_id))\n", " >> collect())\n", - " stop_times = (stop_times >> filter(_.trip_id.isin(trips.trip_id))\n", - " >> select(-_.calitp_itp_id, -_.calitp_extracted_at))\n", + " stop_times = (stop_times >> inner_join(_, trips, on = ['calitp_itp_id', 'calitp_url_number', 'trip_id'])\n", + " >> select(-_.stop_headsign, -_.pickup_type, -_.drop_off_type,\n", + " -_.continuous_pickup, -_.continuous_drop_off, -_.shape_dist_travelled,\n", + " -_.timepoint)\n", + " )\n", " print('loaded stop times')\n", "\n", " stops = (tbl.gtfs_schedule.stops() \n", @@ -292,7 +311,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 13, "id": "1049eee5-d4d9-43a1-9a84-c3bd3687f6d3", "metadata": {}, "outputs": [], @@ -313,7 +332,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 61, "id": "0d3207be-d38f-4f17-a97f-0f84cae25d77", "metadata": {}, "outputs": [], @@ -430,6 +449,7 @@ " segment_peak_service['next_seg_hqta'] = segment_peak_service['hq_transit_corr'].shift(-1)\n", " \n", " ## consider segment not HQTA if both the prior and next segements are not HQTAs\n", + " debug_dict[f'{shape_id}_sps'] = segments_with_max_stop >> inner_join(_, segment_peak_service, on = 'hqta_segment_id')\n", " segment_peak_service['hq_transit_corr'] = segment_peak_service.apply(\n", " lambda x: False if x.hq_transit_corr == False else x.last_seg_hqta or x.next_seg_hqta, axis = 1)\n", " segment_peak_service['hq_transit_corr'] = segment_peak_service['hq_transit_corr'].fillna(True)\n", @@ -446,7 +466,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 31, "id": "9483141f-c197-4fc8-80f0-4efa8d2b44c4", "metadata": {}, "outputs": [], @@ -490,81 +510,2208 @@ " hqta = hqta.set_crs('EPSG:6414')\n", " except:\n", " continue\n", - " \n", - " return hqta.drop(columns=['n', 'departure_hour']).reset_index(drop=True)" + " return hqta\n", + " # return hqta.drop(columns=['n', 'departure_hour']).reset_index(drop=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "e9d94df4-21cd-46d6-a8ab-fe4d4c01d728", + "metadata": {}, + "outputs": [], + "source": [ + "debug_ids = ['940143', '1730123']" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "54227d0f-b539-4852-96e2-50472f40fb08", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "loaded shapes\n", + "loaded bus routes\n", + "loaded trips\n", + "loaded stop times\n", + "loaded stops\n" + ] + } + ], + "source": [ + "lbt_views = get_operator_views(170)" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "id": "f6c92a46-4a65-4a0f-9bbc-a9d9050417d0", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "there are 100 shapes total\n", + "calculating for shape_id 510066\n", + "progress: 0/100 shapes (0.0%)\n", + "calculating for shape_id 610106\n", + "calculating for shape_id 610105\n", + "calculating for shape_id 510067\n", + "calculating for shape_id 1210143\n", + "calculating for shape_id 460064\n", + "calculating for shape_id 1210138\n", + "calculating for shape_id 460067\n", + "no line for shape 460067\n", + "calculating for shape_id 1920161\n", + "calculating for shape_id 1920167\n", + "calculating for shape_id 1730123\n", + "***debug shape*** 1730123\n", + "calculating for shape_id 1910292\n", + "calculating for shape_id 1910295\n", + "calculating for shape_id 1730122\n", + "calculating for shape_id 220068\n", + "calculating for shape_id 220074\n", + "calculating for shape_id 1710168\n", + "calculating for shape_id 1710162\n", + "calculating for shape_id 1720090\n", + "calculating for shape_id 1720091\n", + "no line for shape 1720091\n", + "calculating for shape_id 10070\n", + "calculating for shape_id 20008\n", + "calculating for shape_id 40001\n", + "calculating for shape_id 40002\n", + "no line for shape 40002\n", + "calculating for shape_id 410006\n", + "calculating for shape_id 80002\n", + "progress: 25/100 shapes (25.0%)\n", + "calculating for shape_id 10069\n", + "no line for shape 10069\n", + "calculating for shape_id 80003\n", + "no line for shape 80003\n", + "calculating for shape_id 1510067\n", + "calculating for shape_id 20010\n", + "calculating for shape_id 450111\n", + "no line for shape 450111\n", + "calculating for shape_id 710048\n", + "calculating for shape_id 1750012\n", + "no line for shape 1750012\n", + "calculating for shape_id 1510064\n", + "calculating for shape_id 450110\n", + "calculating for shape_id 410007\n", + "no line for shape 410007\n", + "calculating for shape_id 710046\n", + "calculating for shape_id 1040017\n", + "calculating for shape_id 1310131\n", + "calculating for shape_id 1310132\n", + "no stops for shape 1310132\n", + "calculating for shape_id 1040018\n", + "calculating for shape_id 1750010\n", + "no stops for shape 1750010\n", + "calculating for shape_id 910129\n", + "calculating for shape_id 1010081\n", + "calculating for shape_id 1030063\n", + "calculating for shape_id 910132\n", + "calculating for shape_id 1010082\n", + "no line for shape 1010082\n", + "calculating for shape_id 1810080\n", + "calculating for shape_id 1030064\n", + "calculating for shape_id 230018\n", + "calculating for shape_id 230015\n", + "progress: 50/100 shapes (50.0%)\n", + "calculating for shape_id 1120045\n", + "calculating for shape_id 1110083\n", + "calculating for shape_id 210080\n", + "calculating for shape_id 210079\n", + "no line for shape 210079\n", + "calculating for shape_id 1820070\n", + "calculating for shape_id 1810081\n", + "calculating for shape_id 1110082\n", + "no stops for shape 1110082\n", + "calculating for shape_id 920113\n", + "calculating for shape_id 1120046\n", + "no line for shape 1120046\n", + "calculating for shape_id 1820071\n", + "no stops for shape 1820071\n", + "calculating for shape_id 930151\n", + "calculating for shape_id 920111\n", + "no stops for shape 920111\n", + "calculating for shape_id 930148\n", + "no stops for shape 930148\n", + "calculating for shape_id 930150\n", + "no line for shape 930150\n", + "calculating for shape_id 930147\n", + "no stops for shape 930147\n", + "calculating for shape_id 920115\n", + "no stops for shape 920115\n", + "calculating for shape_id 920112\n", + "no line for shape 920112\n", + "calculating for shape_id 460065\n", + "no line for shape 460065\n", + "calculating for shape_id 910131\n", + "no line for shape 910131\n", + "calculating for shape_id 910130\n", + "no stops for shape 910130\n", + "calculating for shape_id 460063\n", + "no stops for shape 460063\n", + "calculating for shape_id 460069\n", + "no line for shape 460069\n", + "calculating for shape_id 1720093\n", + "no line for shape 1720093\n", + "calculating for shape_id 1740030\n", + "no stops for shape 1740030\n", + "calculating for shape_id 1720092\n", + "progress: 75/100 shapes (75.0%)\n", + "no stops for shape 1720092\n", + "calculating for shape_id 1510066\n", + "no stops for shape 1510066\n", + "calculating for shape_id 410005\n", + "no line for shape 410005\n", + "calculating for shape_id 4050003\n", + "calculating for shape_id 910140\n", + "no line for shape 910140\n", + "calculating for shape_id 4050001\n", + "calculating for shape_id 1210141\n", + "no line for shape 1210141\n", + "calculating for shape_id 940134\n", + "no line for shape 940134\n", + "calculating for shape_id 940133\n", + "no line for shape 940133\n", + "calculating for shape_id 210078\n", + "no line for shape 210078\n", + "calculating for shape_id 460075\n", + "no line for shape 460075\n", + "calculating for shape_id 460071\n", + "no line for shape 460071\n", + "calculating for shape_id 450109\n", + "no line for shape 450109\n", + "calculating for shape_id 220073\n", + "no line for shape 220073\n", + "calculating for shape_id 210083\n", + "no line for shape 210083\n", + "calculating for shape_id 1920165\n", + "no line for shape 1920165\n", + "calculating for shape_id 1910305\n", + "no stops for shape 1910305\n", + "calculating for shape_id 1910304\n", + "no line for shape 1910304\n", + "calculating for shape_id 1910302\n", + "no stops for shape 1910302\n", + "calculating for shape_id 1910297\n", + "no stops for shape 1910297\n", + "calculating for shape_id 1910287\n", + "no line for shape 1910287\n", + "calculating for shape_id 1720096\n", + "no line for shape 1720096\n", + "calculating for shape_id 1720095\n", + "no stops for shape 1720095\n", + "calculating for shape_id 1210144\n", + "no line for shape 1210144\n", + "calculating for shape_id 940143\n", + "***debug shape*** 940143\n", + "no line for shape 940143\n" + ] + } + ], + "source": [ + "lbt_hqta = single_operator_hqta(lbt_views)" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "id": "2ab838e9-ba14-4057-a0ab-9e6401e83f16", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idgeometryhqta_segment_idsegment_sequenceshape_idstop_idam_max_tripspm_max_tripshq_transit_corr
0170POLYGON ((167654.764 -470242.512, 167655.638 -...1081235767051006640101616True
1170POLYGON ((167694.221 -469153.485, 167693.191 -...9304416331510066000477True
2170POLYGON ((167669.771 -467897.042, 167669.770 -...29273764112510066169877True
3170POLYGON ((167646.521 -466641.120, 167646.502 -...36487189893510066055044False
4170POLYGON ((167605.970 -464592.739, 167604.537 -...11932541904510066055544False
..............................
8170POLYGON ((167565.314 -466042.457, 167566.287 -...2433783489424050003525111False
9170POLYGON ((167563.316 -466013.754, 167563.368 -...3860309591434050003525111False
10170POLYGON ((167564.027 -466023.335, 167507.511 -...259261282454050003061054False
11170POLYGON ((167584.688 -466111.742, 167498.932 -...2524795608464050003525111False
0170POLYGON ((165145.529 -464024.944, 165145.017 -...123563336844050001013422False
\n", + "

383 rows × 9 columns

\n", + "
" + ], + "text/plain": [ + " calitp_itp_id geometry \\\n", + "0 170 POLYGON ((167654.764 -470242.512, 167655.638 -... \n", + "1 170 POLYGON ((167694.221 -469153.485, 167693.191 -... \n", + "2 170 POLYGON ((167669.771 -467897.042, 167669.770 -... \n", + "3 170 POLYGON ((167646.521 -466641.120, 167646.502 -... \n", + "4 170 POLYGON ((167605.970 -464592.739, 167604.537 -... \n", + ".. ... ... \n", + "8 170 POLYGON ((167565.314 -466042.457, 167566.287 -... \n", + "9 170 POLYGON ((167563.316 -466013.754, 167563.368 -... \n", + "10 170 POLYGON ((167564.027 -466023.335, 167507.511 -... \n", + "11 170 POLYGON ((167584.688 -466111.742, 167498.932 -... \n", + "0 170 POLYGON ((165145.529 -464024.944, 165145.017 -... \n", + "\n", + " hqta_segment_id segment_sequence shape_id stop_id am_max_trips \\\n", + "0 1081235767 0 510066 4010 16 \n", + "1 930441633 1 510066 0004 7 \n", + "2 2927376411 2 510066 1698 7 \n", + "3 3648718989 3 510066 0550 4 \n", + "4 1193254190 4 510066 0555 4 \n", + ".. ... ... ... ... ... \n", + "8 2433783489 42 4050003 5251 1 \n", + "9 3860309591 43 4050003 5251 1 \n", + "10 259261282 45 4050003 0610 5 \n", + "11 2524795608 46 4050003 5251 1 \n", + "0 1235633368 4 4050001 0134 2 \n", + "\n", + " pm_max_trips hq_transit_corr \n", + "0 16 True \n", + "1 7 True \n", + "2 7 True \n", + "3 4 False \n", + "4 4 False \n", + ".. ... ... \n", + "8 1 False \n", + "9 1 False \n", + "10 4 False \n", + "11 1 False \n", + "0 2 False \n", + "\n", + "[383 rows x 9 columns]" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lbt_hqta" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "c5fcee96-a46e-4d56-afe3-717d7841945d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idgeometryhqta_segment_idsegment_sequenceshape_idstop_idam_max_tripspm_max_tripshq_transit_corr
3170POLYGON ((170683.457 -468570.782, 170703.916 -...34621206084460064047766True
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id geometry \\\n", + "3 170 POLYGON ((170683.457 -468570.782, 170703.916 -... \n", + "\n", + " hqta_segment_id segment_sequence shape_id stop_id am_max_trips \\\n", + "3 3462120608 4 460064 0477 6 \n", + "\n", + " pm_max_trips hq_transit_corr \n", + "3 6 True " + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lbt_hqta >> filter(_.stop_id == '0477')" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "id": "1d258bdf-1164-4036-a16f-c7f942711c3f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Int64Index: 383 entries, 0 to 0\n", + "Data columns (total 9 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 calitp_itp_id 383 non-null object \n", + " 1 geometry 383 non-null geometry\n", + " 2 hqta_segment_id 383 non-null int64 \n", + " 3 segment_sequence 383 non-null object \n", + " 4 shape_id 383 non-null object \n", + " 5 stop_id 383 non-null object \n", + " 6 am_max_trips 383 non-null int64 \n", + " 7 pm_max_trips 383 non-null int64 \n", + " 8 hq_transit_corr 383 non-null bool \n", + "dtypes: bool(1), geometry(1), int64(3), object(4)\n", + "memory usage: 27.3+ KB\n" + ] + } + ], + "source": [ + "lbt_hqta.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "id": "8c170b28-4de1-4ac1-b265-920ec3a976b4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['510066', '610106', '610105', '510067', '1210143', '460064',\n", + " '1210138', '1920161', '1920167', '1730123', '1910292', '1910295',\n", + " '1730122', '220068', '220074', '1710168', '1710162', '1720090',\n", + " '10070', '20008', '40001', '410006', '80002', '1510067', '20010',\n", + " '710048', '1510064', '450110', '710046', '1040017', '1310131',\n", + " '1040018', '910129', '1010081', '1030063', '910132', '1810080',\n", + " '1030064', '230018', '230015', '1120045', '1110083', '210080',\n", + " '1820070', '1810081', '920113', '930151', '4050003', '4050001'],\n", + " dtype=object)" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lbt_hqta.shape_id.unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "id": "f03f090c-2508-46a4-b705-18df2c015186", + "metadata": {}, + "outputs": [], + "source": [ + "# map_hqta(lbt_hqta, 'hqta_segment_id')" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "id": "c19aba0b-b265-4cfe-8e76-0fca0447acda", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9d4124fffa3849d38d4e43275c918518", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[33.91231602534506, -118.10067122142928], controls=(ZoomControl(options=['position', 'zoom_in_text'…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "map_hqta(lbt_hqta >> filter(_.shape_id == '1730123'), 'stop_id')" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "id": "4e62a18b-a65f-4027-87f2-7da1227a4d3b", + "metadata": {}, + "outputs": [], + "source": [ + "## investigate PCH not being an hqta..." + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "id": "970b2cb6-7511-44be-bfb1-4d1c1d1bfe2b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idgeometryhqta_segment_idsegment_sequenceshape_idstop_idam_max_tripspm_max_tripshq_transit_corr
0170POLYGON ((175350.451 -454051.814, 175349.213 -...263163155101730123411355True
1170POLYGON ((175836.936 -454587.721, 175836.959 -...395710928911730123411632False
2170POLYGON ((175798.075 -455972.107, 175798.083 -...192662005121730123411932False
3170POLYGON ((175827.602 -457076.012, 175827.610 -...9770266131730123303332False
4170POLYGON ((175854.103 -458921.667, 175854.135 -...261241411841730123412432False
5170POLYGON ((176737.013 -460049.998, 176737.342 -...397105310451730123190933False
6170POLYGON ((177991.832 -460007.766, 178010.111 -...197500301861730123190222False
7170POLYGON ((178396.327 -461576.519, 178395.927 -...4607772471730123156933False
8170POLYGON ((178429.971 -462989.509, 178430.591 -...244947623781730123180255False
9170POLYGON ((178152.046 -463095.761, 178090.699 -...384245609191730123127243False
10170POLYGON ((175975.412 -463280.594, 175977.308 -...3062012927101730123197243False
11170POLYGON ((175919.561 -463405.079, 175916.534 -...3246762857111730123179522False
12170POLYGON ((176053.775 -464584.739, 176053.777 -...1485634259121730123179222False
13170POLYGON ((176068.527 -465823.921, 176068.537 -...797690437131730123178822False
14170POLYGON ((175997.767 -467784.889, 175997.533 -...2985254886141730123052922False
15170POLYGON ((175564.080 -467890.219, 175563.606 -...3337121648151730123052722False
16170POLYGON ((173784.416 -467841.455, 173785.048 -...1608597194161730123177922False
17170POLYGON ((171789.381 -467743.362, 171793.498 -...686165596171730123134677False
18170POLYGON ((171187.739 -467856.064, 171187.546 -...3092845517181730123167277False
19170POLYGON ((169935.539 -467879.393, 169923.522 -...3479053147191730123166777False
20170POLYGON ((168696.051 -467903.956, 168680.399 -...2645542972201730123166377True
21170POLYGON ((168037.524 -467916.250, 168037.372 -...3936942250211730123166277False
22170POLYGON ((167357.829 -467928.625, 167358.227 -...1939974416221730123005478False
23170POLYGON ((167281.629 -469235.162, 167281.182 -...7802714223173012303601010False
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id geometry \\\n", + "0 170 POLYGON ((175350.451 -454051.814, 175349.213 -... \n", + "1 170 POLYGON ((175836.936 -454587.721, 175836.959 -... \n", + "2 170 POLYGON ((175798.075 -455972.107, 175798.083 -... \n", + "3 170 POLYGON ((175827.602 -457076.012, 175827.610 -... \n", + "4 170 POLYGON ((175854.103 -458921.667, 175854.135 -... \n", + "5 170 POLYGON ((176737.013 -460049.998, 176737.342 -... \n", + "6 170 POLYGON ((177991.832 -460007.766, 178010.111 -... \n", + "7 170 POLYGON ((178396.327 -461576.519, 178395.927 -... \n", + "8 170 POLYGON ((178429.971 -462989.509, 178430.591 -... \n", + "9 170 POLYGON ((178152.046 -463095.761, 178090.699 -... \n", + "10 170 POLYGON ((175975.412 -463280.594, 175977.308 -... \n", + "11 170 POLYGON ((175919.561 -463405.079, 175916.534 -... \n", + "12 170 POLYGON ((176053.775 -464584.739, 176053.777 -... \n", + "13 170 POLYGON ((176068.527 -465823.921, 176068.537 -... \n", + "14 170 POLYGON ((175997.767 -467784.889, 175997.533 -... \n", + "15 170 POLYGON ((175564.080 -467890.219, 175563.606 -... \n", + "16 170 POLYGON ((173784.416 -467841.455, 173785.048 -... \n", + "17 170 POLYGON ((171789.381 -467743.362, 171793.498 -... \n", + "18 170 POLYGON ((171187.739 -467856.064, 171187.546 -... \n", + "19 170 POLYGON ((169935.539 -467879.393, 169923.522 -... \n", + "20 170 POLYGON ((168696.051 -467903.956, 168680.399 -... \n", + "21 170 POLYGON ((168037.524 -467916.250, 168037.372 -... \n", + "22 170 POLYGON ((167357.829 -467928.625, 167358.227 -... \n", + "23 170 POLYGON ((167281.629 -469235.162, 167281.182 -... \n", + "\n", + " hqta_segment_id segment_sequence shape_id stop_id am_max_trips \\\n", + "0 2631631551 0 1730123 4113 5 \n", + "1 3957109289 1 1730123 4116 3 \n", + "2 1926620051 2 1730123 4119 3 \n", + "3 97702661 3 1730123 3033 3 \n", + "4 2612414118 4 1730123 4124 3 \n", + "5 3971053104 5 1730123 1909 3 \n", + "6 1975003018 6 1730123 1902 2 \n", + "7 46077724 7 1730123 1569 3 \n", + "8 2449476237 8 1730123 1802 5 \n", + "9 3842456091 9 1730123 1272 4 \n", + "10 3062012927 10 1730123 1972 4 \n", + "11 3246762857 11 1730123 1795 2 \n", + "12 1485634259 12 1730123 1792 2 \n", + "13 797690437 13 1730123 1788 2 \n", + "14 2985254886 14 1730123 0529 2 \n", + "15 3337121648 15 1730123 0527 2 \n", + "16 1608597194 16 1730123 1779 2 \n", + "17 686165596 17 1730123 1346 7 \n", + "18 3092845517 18 1730123 1672 7 \n", + "19 3479053147 19 1730123 1667 7 \n", + "20 2645542972 20 1730123 1663 7 \n", + "21 3936942250 21 1730123 1662 7 \n", + "22 1939974416 22 1730123 0054 7 \n", + "23 78027142 23 1730123 0360 10 \n", + "\n", + " pm_max_trips hq_transit_corr \n", + "0 5 True \n", + "1 2 False \n", + "2 2 False \n", + "3 2 False \n", + "4 2 False \n", + "5 3 False \n", + "6 2 False \n", + "7 3 False \n", + "8 5 False \n", + "9 3 False \n", + "10 3 False \n", + "11 2 False \n", + "12 2 False \n", + "13 2 False \n", + "14 2 False \n", + "15 2 False \n", + "16 2 False \n", + "17 7 False \n", + "18 7 False \n", + "19 7 False \n", + "20 7 True \n", + "21 7 False \n", + "22 8 False \n", + "23 10 False " + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lbt_hqta >> filter(_.shape_id == '1730123')" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "id": "144e0093-693f-4fa3-b1f4-849f763a9f28", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
indexcalitp_itp_idshape_idcalitp_extracted_atgeometrysegment_sequencehqta_segment_idstop_idn_tripsam_max_tripspm_max_tripshq_transit_corrlast_seg_hqtanext_seg_hqta
0017017301232021-10-06POLYGON ((175350.451 -454051.814, 175349.213 -...0263163155141136955TrueFalseTrue
1017017301232021-10-06POLYGON ((175836.936 -454587.721, 175836.959 -...1395710928941163532FalseTrueFalse
2017017301232021-10-06POLYGON ((175798.075 -455972.107, 175798.083 -...2192662005141193532FalseFalseTrue
3017017301232021-10-06POLYGON ((175827.602 -457076.012, 175827.610 -...39770266130333532FalseTrueTrue
4017017301232021-10-06POLYGON ((175854.103 -458921.667, 175854.135 -...4261241411841243532FalseTrueTrue
5017017301232021-10-06POLYGON ((176737.013 -460049.998, 176737.342 -...5397105310419093433FalseFalseNaN
6017017301232021-10-06POLYGON ((177991.832 -460007.766, 178010.111 -...6197500301819023122FalseTrueTrue
7017017301232021-10-06POLYGON ((178396.327 -461576.519, 178395.927 -...74607772415693233FalseNaNTrue
8017017301232021-10-06POLYGON ((178429.971 -462989.509, 178430.591 -...8244947623718027255TrueFalseFalse
9017017301232021-10-06POLYGON ((178152.046 -463095.761, 178090.699 -...9384245609112724943FalseTrueTrue
10017017301232021-10-06POLYGON ((175975.412 -463280.594, 175977.308 -...10306201292719724943FalseFalseTrue
11017017301232021-10-06POLYGON ((175919.561 -463405.079, 175916.534 -...11324676285717953122FalseTrueFalse
12017017301232021-10-06POLYGON ((176053.775 -464584.739, 176053.777 -...12148563425917923122FalseFalseFalse
13017017301232021-10-06POLYGON ((176068.527 -465823.921, 176068.537 -...1379769043717883122FalseTrueFalse
14017017301232021-10-06POLYGON ((175997.767 -467784.889, 175997.533 -...14298525488605293122FalseTrueFalse
15017017301232021-10-06POLYGON ((175564.080 -467890.219, 175563.606 -...15333712164805273122FalseFalseTrue
16017017301232021-10-06POLYGON ((173784.416 -467841.455, 173785.048 -...16160859719417793122FalseFalseFalse
17017017301232021-10-06POLYGON ((171789.381 -467743.362, 171793.498 -...17686165596134611077TrueFalseFalse
18017017301232021-10-06POLYGON ((171187.739 -467856.064, 171187.546 -...183092845517167211077TrueFalseFalse
19017017301232021-10-06POLYGON ((169935.539 -467879.393, 169923.522 -...193479053147166711077TrueFalseFalse
20017017301232021-10-06POLYGON ((168696.051 -467903.956, 168680.399 -...202645542972166311077TrueTrueFalse
21017017301232021-10-06POLYGON ((168037.524 -467916.250, 168037.372 -...213936942250166211077TrueFalseFalse
22017017301232021-10-06POLYGON ((167357.829 -467928.625, 167358.227 -...221939974416005411078TrueFalseFalse
23017017301232021-10-06POLYGON ((167281.629 -469235.162, 167281.182 -...237802714203601521010TrueFalseFalse
\n", + "
" + ], + "text/plain": [ + " index calitp_itp_id shape_id calitp_extracted_at \\\n", + "0 0 170 1730123 2021-10-06 \n", + "1 0 170 1730123 2021-10-06 \n", + "2 0 170 1730123 2021-10-06 \n", + "3 0 170 1730123 2021-10-06 \n", + "4 0 170 1730123 2021-10-06 \n", + "5 0 170 1730123 2021-10-06 \n", + "6 0 170 1730123 2021-10-06 \n", + "7 0 170 1730123 2021-10-06 \n", + "8 0 170 1730123 2021-10-06 \n", + "9 0 170 1730123 2021-10-06 \n", + "10 0 170 1730123 2021-10-06 \n", + "11 0 170 1730123 2021-10-06 \n", + "12 0 170 1730123 2021-10-06 \n", + "13 0 170 1730123 2021-10-06 \n", + "14 0 170 1730123 2021-10-06 \n", + "15 0 170 1730123 2021-10-06 \n", + "16 0 170 1730123 2021-10-06 \n", + "17 0 170 1730123 2021-10-06 \n", + "18 0 170 1730123 2021-10-06 \n", + "19 0 170 1730123 2021-10-06 \n", + "20 0 170 1730123 2021-10-06 \n", + "21 0 170 1730123 2021-10-06 \n", + "22 0 170 1730123 2021-10-06 \n", + "23 0 170 1730123 2021-10-06 \n", + "\n", + " geometry segment_sequence \\\n", + "0 POLYGON ((175350.451 -454051.814, 175349.213 -... 0 \n", + "1 POLYGON ((175836.936 -454587.721, 175836.959 -... 1 \n", + "2 POLYGON ((175798.075 -455972.107, 175798.083 -... 2 \n", + "3 POLYGON ((175827.602 -457076.012, 175827.610 -... 3 \n", + "4 POLYGON ((175854.103 -458921.667, 175854.135 -... 4 \n", + "5 POLYGON ((176737.013 -460049.998, 176737.342 -... 5 \n", + "6 POLYGON ((177991.832 -460007.766, 178010.111 -... 6 \n", + "7 POLYGON ((178396.327 -461576.519, 178395.927 -... 7 \n", + "8 POLYGON ((178429.971 -462989.509, 178430.591 -... 8 \n", + "9 POLYGON ((178152.046 -463095.761, 178090.699 -... 9 \n", + "10 POLYGON ((175975.412 -463280.594, 175977.308 -... 10 \n", + "11 POLYGON ((175919.561 -463405.079, 175916.534 -... 11 \n", + "12 POLYGON ((176053.775 -464584.739, 176053.777 -... 12 \n", + "13 POLYGON ((176068.527 -465823.921, 176068.537 -... 13 \n", + "14 POLYGON ((175997.767 -467784.889, 175997.533 -... 14 \n", + "15 POLYGON ((175564.080 -467890.219, 175563.606 -... 15 \n", + "16 POLYGON ((173784.416 -467841.455, 173785.048 -... 16 \n", + "17 POLYGON ((171789.381 -467743.362, 171793.498 -... 17 \n", + "18 POLYGON ((171187.739 -467856.064, 171187.546 -... 18 \n", + "19 POLYGON ((169935.539 -467879.393, 169923.522 -... 19 \n", + "20 POLYGON ((168696.051 -467903.956, 168680.399 -... 20 \n", + "21 POLYGON ((168037.524 -467916.250, 168037.372 -... 21 \n", + "22 POLYGON ((167357.829 -467928.625, 167358.227 -... 22 \n", + "23 POLYGON ((167281.629 -469235.162, 167281.182 -... 23 \n", + "\n", + " hqta_segment_id stop_id n_trips am_max_trips pm_max_trips \\\n", + "0 2631631551 4113 69 5 5 \n", + "1 3957109289 4116 35 3 2 \n", + "2 1926620051 4119 35 3 2 \n", + "3 97702661 3033 35 3 2 \n", + "4 2612414118 4124 35 3 2 \n", + "5 3971053104 1909 34 3 3 \n", + "6 1975003018 1902 31 2 2 \n", + "7 46077724 1569 32 3 3 \n", + "8 2449476237 1802 72 5 5 \n", + "9 3842456091 1272 49 4 3 \n", + "10 3062012927 1972 49 4 3 \n", + "11 3246762857 1795 31 2 2 \n", + "12 1485634259 1792 31 2 2 \n", + "13 797690437 1788 31 2 2 \n", + "14 2985254886 0529 31 2 2 \n", + "15 3337121648 0527 31 2 2 \n", + "16 1608597194 1779 31 2 2 \n", + "17 686165596 1346 110 7 7 \n", + "18 3092845517 1672 110 7 7 \n", + "19 3479053147 1667 110 7 7 \n", + "20 2645542972 1663 110 7 7 \n", + "21 3936942250 1662 110 7 7 \n", + "22 1939974416 0054 110 7 8 \n", + "23 78027142 0360 152 10 10 \n", + "\n", + " hq_transit_corr last_seg_hqta next_seg_hqta \n", + "0 True False True \n", + "1 False True False \n", + "2 False False True \n", + "3 False True True \n", + "4 False True True \n", + "5 False False NaN \n", + "6 False True True \n", + "7 False NaN True \n", + "8 True False False \n", + "9 False True True \n", + "10 False False True \n", + "11 False True False \n", + "12 False False False \n", + "13 False True False \n", + "14 False True False \n", + "15 False False True \n", + "16 False False False \n", + "17 True False False \n", + "18 True False False \n", + "19 True False False \n", + "20 True True False \n", + "21 True False False \n", + "22 True False False \n", + "23 True False False " + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sps = debug_dict['1730123_sps']\n", + "sps" ] }, { "cell_type": "code", - "execution_count": 13, - "id": "e9d94df4-21cd-46d6-a8ab-fe4d4c01d728", + "execution_count": 73, + "id": "aa772241-9e43-47eb-b2a2-5e9c727cc46c", "metadata": {}, "outputs": [], "source": [ - "debug_ids = ['25349']" + "sps['hq_transit_corr'] = sps.apply(\n", + " lambda x: False if x.hq_transit_corr == False else x.last_seg_hqta or x.next_seg_hqta, axis = 1)\n", + "sps['hq_transit_corr'] = sps['hq_transit_corr'].fillna(True)" ] }, { "cell_type": "code", - "execution_count": 29, - "id": "b1089592-7a20-4c3b-a27f-5eb6193213de", + "execution_count": 74, + "id": "efbd4c3b-77f8-4385-b00d-993beb00057f", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "loaded shapes\n", - "loaded bus routes\n", - "loaded trips\n", - "loaded stop times\n", - "loaded stops\n" - ] - } - ], - "source": [ - "bbb_views = get_operator_views(300)" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "id": "f6c92a46-4a65-4a0f-9bbc-a9d9050417d0", - "metadata": { - "collapsed": true, - "jupyter": { - "outputs_hidden": true - }, - "tags": [] - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "there are 0 shapes total\n" - ] - }, - { - "ename": "KeyError", - "evalue": "\"['n' 'departure_hour'] not found in axis\"", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_46/1844755579.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mbart_hqta\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msingle_operator_hqta\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbart_views\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m/tmp/ipykernel_46/483469756.py\u001b[0m in \u001b[0;36msingle_operator_hqta\u001b[0;34m(views)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0;32mcontinue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mhqta\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdrop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'n'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'departure_hour'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreset_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdrop\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m/opt/conda/lib/python3.9/site-packages/pandas/util/_decorators.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 309\u001b[0m \u001b[0mstacklevel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mstacklevel\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 310\u001b[0m )\n\u001b[0;32m--> 311\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 312\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 313\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/opt/conda/lib/python3.9/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36mdrop\u001b[0;34m(self, labels, axis, index, columns, level, inplace, errors)\u001b[0m\n\u001b[1;32m 4904\u001b[0m \u001b[0mweight\u001b[0m \u001b[0;36m1.0\u001b[0m \u001b[0;36m0.8\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4905\u001b[0m \"\"\"\n\u001b[0;32m-> 4906\u001b[0;31m return super().drop(\n\u001b[0m\u001b[1;32m 4907\u001b[0m \u001b[0mlabels\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlabels\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4908\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/opt/conda/lib/python3.9/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36mdrop\u001b[0;34m(self, labels, axis, index, columns, level, inplace, errors)\u001b[0m\n\u001b[1;32m 4148\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlabels\u001b[0m \u001b[0;32min\u001b[0m \u001b[0maxes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4149\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlabels\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 4150\u001b[0;31m \u001b[0mobj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mobj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_drop_axis\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlevel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merrors\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0merrors\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4151\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4152\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0minplace\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/opt/conda/lib/python3.9/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36m_drop_axis\u001b[0;34m(self, labels, axis, level, errors)\u001b[0m\n\u001b[1;32m 4183\u001b[0m \u001b[0mnew_axis\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdrop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlevel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merrors\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0merrors\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4184\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 4185\u001b[0;31m \u001b[0mnew_axis\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdrop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merrors\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0merrors\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4186\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0maxis_name\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mnew_axis\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4187\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/opt/conda/lib/python3.9/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mdrop\u001b[0;34m(self, labels, errors)\u001b[0m\n\u001b[1;32m 6015\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmask\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0many\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6016\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0merrors\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;34m\"ignore\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 6017\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"{labels[mask]} not found in axis\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6018\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m~\u001b[0m\u001b[0mmask\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6019\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdelete\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: \"['n' 'departure_hour'] not found in axis\"" - ] + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
indexcalitp_itp_idshape_idcalitp_extracted_atgeometrysegment_sequencehqta_segment_idstop_idn_tripsam_max_tripspm_max_tripshq_transit_corrlast_seg_hqtanext_seg_hqta
0017017301232021-10-06POLYGON ((175350.451 -454051.814, 175349.213 -...0263163155141136955TrueFalseTrue
1017017301232021-10-06POLYGON ((175836.936 -454587.721, 175836.959 -...1395710928941163532FalseTrueFalse
2017017301232021-10-06POLYGON ((175798.075 -455972.107, 175798.083 -...2192662005141193532FalseFalseTrue
3017017301232021-10-06POLYGON ((175827.602 -457076.012, 175827.610 -...39770266130333532FalseTrueTrue
4017017301232021-10-06POLYGON ((175854.103 -458921.667, 175854.135 -...4261241411841243532FalseTrueTrue
5017017301232021-10-06POLYGON ((176737.013 -460049.998, 176737.342 -...5397105310419093433FalseFalseNaN
6017017301232021-10-06POLYGON ((177991.832 -460007.766, 178010.111 -...6197500301819023122FalseTrueTrue
7017017301232021-10-06POLYGON ((178396.327 -461576.519, 178395.927 -...74607772415693233FalseNaNTrue
8017017301232021-10-06POLYGON ((178429.971 -462989.509, 178430.591 -...8244947623718027255FalseFalseFalse
9017017301232021-10-06POLYGON ((178152.046 -463095.761, 178090.699 -...9384245609112724943FalseTrueTrue
10017017301232021-10-06POLYGON ((175975.412 -463280.594, 175977.308 -...10306201292719724943FalseFalseTrue
11017017301232021-10-06POLYGON ((175919.561 -463405.079, 175916.534 -...11324676285717953122FalseTrueFalse
12017017301232021-10-06POLYGON ((176053.775 -464584.739, 176053.777 -...12148563425917923122FalseFalseFalse
13017017301232021-10-06POLYGON ((176068.527 -465823.921, 176068.537 -...1379769043717883122FalseTrueFalse
14017017301232021-10-06POLYGON ((175997.767 -467784.889, 175997.533 -...14298525488605293122FalseTrueFalse
15017017301232021-10-06POLYGON ((175564.080 -467890.219, 175563.606 -...15333712164805273122FalseFalseTrue
16017017301232021-10-06POLYGON ((173784.416 -467841.455, 173785.048 -...16160859719417793122FalseFalseFalse
17017017301232021-10-06POLYGON ((171789.381 -467743.362, 171793.498 -...17686165596134611077FalseFalseFalse
18017017301232021-10-06POLYGON ((171187.739 -467856.064, 171187.546 -...183092845517167211077FalseFalseFalse
19017017301232021-10-06POLYGON ((169935.539 -467879.393, 169923.522 -...193479053147166711077FalseFalseFalse
20017017301232021-10-06POLYGON ((168696.051 -467903.956, 168680.399 -...202645542972166311077TrueTrueFalse
21017017301232021-10-06POLYGON ((168037.524 -467916.250, 168037.372 -...213936942250166211077FalseFalseFalse
22017017301232021-10-06POLYGON ((167357.829 -467928.625, 167358.227 -...221939974416005411078FalseFalseFalse
23017017301232021-10-06POLYGON ((167281.629 -469235.162, 167281.182 -...237802714203601521010FalseFalseFalse
\n", + "
" + ], + "text/plain": [ + " index calitp_itp_id shape_id calitp_extracted_at \\\n", + "0 0 170 1730123 2021-10-06 \n", + "1 0 170 1730123 2021-10-06 \n", + "2 0 170 1730123 2021-10-06 \n", + "3 0 170 1730123 2021-10-06 \n", + "4 0 170 1730123 2021-10-06 \n", + "5 0 170 1730123 2021-10-06 \n", + "6 0 170 1730123 2021-10-06 \n", + "7 0 170 1730123 2021-10-06 \n", + "8 0 170 1730123 2021-10-06 \n", + "9 0 170 1730123 2021-10-06 \n", + "10 0 170 1730123 2021-10-06 \n", + "11 0 170 1730123 2021-10-06 \n", + "12 0 170 1730123 2021-10-06 \n", + "13 0 170 1730123 2021-10-06 \n", + "14 0 170 1730123 2021-10-06 \n", + "15 0 170 1730123 2021-10-06 \n", + "16 0 170 1730123 2021-10-06 \n", + "17 0 170 1730123 2021-10-06 \n", + "18 0 170 1730123 2021-10-06 \n", + "19 0 170 1730123 2021-10-06 \n", + "20 0 170 1730123 2021-10-06 \n", + "21 0 170 1730123 2021-10-06 \n", + "22 0 170 1730123 2021-10-06 \n", + "23 0 170 1730123 2021-10-06 \n", + "\n", + " geometry segment_sequence \\\n", + "0 POLYGON ((175350.451 -454051.814, 175349.213 -... 0 \n", + "1 POLYGON ((175836.936 -454587.721, 175836.959 -... 1 \n", + "2 POLYGON ((175798.075 -455972.107, 175798.083 -... 2 \n", + "3 POLYGON ((175827.602 -457076.012, 175827.610 -... 3 \n", + "4 POLYGON ((175854.103 -458921.667, 175854.135 -... 4 \n", + "5 POLYGON ((176737.013 -460049.998, 176737.342 -... 5 \n", + "6 POLYGON ((177991.832 -460007.766, 178010.111 -... 6 \n", + "7 POLYGON ((178396.327 -461576.519, 178395.927 -... 7 \n", + "8 POLYGON ((178429.971 -462989.509, 178430.591 -... 8 \n", + "9 POLYGON ((178152.046 -463095.761, 178090.699 -... 9 \n", + "10 POLYGON ((175975.412 -463280.594, 175977.308 -... 10 \n", + "11 POLYGON ((175919.561 -463405.079, 175916.534 -... 11 \n", + "12 POLYGON ((176053.775 -464584.739, 176053.777 -... 12 \n", + "13 POLYGON ((176068.527 -465823.921, 176068.537 -... 13 \n", + "14 POLYGON ((175997.767 -467784.889, 175997.533 -... 14 \n", + "15 POLYGON ((175564.080 -467890.219, 175563.606 -... 15 \n", + "16 POLYGON ((173784.416 -467841.455, 173785.048 -... 16 \n", + "17 POLYGON ((171789.381 -467743.362, 171793.498 -... 17 \n", + "18 POLYGON ((171187.739 -467856.064, 171187.546 -... 18 \n", + "19 POLYGON ((169935.539 -467879.393, 169923.522 -... 19 \n", + "20 POLYGON ((168696.051 -467903.956, 168680.399 -... 20 \n", + "21 POLYGON ((168037.524 -467916.250, 168037.372 -... 21 \n", + "22 POLYGON ((167357.829 -467928.625, 167358.227 -... 22 \n", + "23 POLYGON ((167281.629 -469235.162, 167281.182 -... 23 \n", + "\n", + " hqta_segment_id stop_id n_trips am_max_trips pm_max_trips \\\n", + "0 2631631551 4113 69 5 5 \n", + "1 3957109289 4116 35 3 2 \n", + "2 1926620051 4119 35 3 2 \n", + "3 97702661 3033 35 3 2 \n", + "4 2612414118 4124 35 3 2 \n", + "5 3971053104 1909 34 3 3 \n", + "6 1975003018 1902 31 2 2 \n", + "7 46077724 1569 32 3 3 \n", + "8 2449476237 1802 72 5 5 \n", + "9 3842456091 1272 49 4 3 \n", + "10 3062012927 1972 49 4 3 \n", + "11 3246762857 1795 31 2 2 \n", + "12 1485634259 1792 31 2 2 \n", + "13 797690437 1788 31 2 2 \n", + "14 2985254886 0529 31 2 2 \n", + "15 3337121648 0527 31 2 2 \n", + "16 1608597194 1779 31 2 2 \n", + "17 686165596 1346 110 7 7 \n", + "18 3092845517 1672 110 7 7 \n", + "19 3479053147 1667 110 7 7 \n", + "20 2645542972 1663 110 7 7 \n", + "21 3936942250 1662 110 7 7 \n", + "22 1939974416 0054 110 7 8 \n", + "23 78027142 0360 152 10 10 \n", + "\n", + " hq_transit_corr last_seg_hqta next_seg_hqta \n", + "0 True False True \n", + "1 False True False \n", + "2 False False True \n", + "3 False True True \n", + "4 False True True \n", + "5 False False NaN \n", + "6 False True True \n", + "7 False NaN True \n", + "8 False False False \n", + "9 False True True \n", + "10 False False True \n", + "11 False True False \n", + "12 False False False \n", + "13 False True False \n", + "14 False True False \n", + "15 False False True \n", + "16 False False False \n", + "17 False False False \n", + "18 False False False \n", + "19 False False False \n", + "20 True True False \n", + "21 False False False \n", + "22 False False False \n", + "23 False False False " + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "bbb_hqta = single_operator_hqta(300)" + "sps" ] }, { @@ -628,7 +2775,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 3, "id": "7968cab1-fb27-43b7-ad4c-4b84e03cee81", "metadata": {}, "outputs": [], @@ -1452,7 +3599,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 4, "id": "dd0aada1-9341-4837-978b-0e4c01bec26a", "metadata": {}, "outputs": [], @@ -1462,7 +3609,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 5, "id": "007242a3-d4d2-4acd-8bff-169fc513ad2b", "metadata": {}, "outputs": [], @@ -1472,7 +3619,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 6, "id": "e85121b8-8052-4bd2-9270-fc7462700a58", "metadata": {}, "outputs": [], @@ -1482,7 +3629,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 7, "id": "baaa3b22-d2dd-4afb-a081-e666a0037e8e", "metadata": {}, "outputs": [], @@ -1492,7 +3639,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 8, "id": "090dd0b2-4de3-47b0-abed-9d16356bbf2c", "metadata": {}, "outputs": [], @@ -1500,6 +3647,41 @@ "dissolved = dissolved[dissolved['geometry'].area > 50*3000] ##50m width * 3000m shape min" ] }, + { + "cell_type": "code", + "execution_count": 37, + "id": "ca18f616-9719-458d-beb6-e3aa7492fd32", + "metadata": {}, + "outputs": [], + "source": [ + "dissolved = gpd.read_parquet(f'{GCS_FILE_PATH}shape_hqta_dissolve.parquet')" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "b340161b-cd68-4cef-90ba-7f9f83fe30b0", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4affcd4b579e4b049b95f07f8e24a36f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[33.596015707487744, -117.87571863402819], controls=(ZoomControl(options=['position', 'zoom_in_text…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "map_hqta(dissolved)" + ] + }, { "cell_type": "code", "execution_count": 14, diff --git a/high_quality_transit_areas/catalog.yml b/high_quality_transit_areas/catalog.yml new file mode 100644 index 000000000..58e7a59a4 --- /dev/null +++ b/high_quality_transit_areas/catalog.yml @@ -0,0 +1,10 @@ +metadata: + version: 1 +sources: + stanford_shorelines: + driver: shapefile + description: Stanford shoreline data + url: https://earthworks.stanford.edu/catalog/stanford-vt021tk4894 + args: + urlpath: gs://calitp-analytics-data/data-analyses/msd_dashboard_metric/stanford_shorelines.zip + use_fsspec: true \ No newline at end of file diff --git a/high_quality_transit_areas/combine_and_visualize.ipynb b/high_quality_transit_areas/combine_and_visualize.ipynb index a8ac4cfd1..0a79cce07 100644 --- a/high_quality_transit_areas/combine_and_visualize.ipynb +++ b/high_quality_transit_areas/combine_and_visualize.ipynb @@ -2,109 +2,22 @@ "cells": [ { "cell_type": "code", - "execution_count": 6, + "execution_count": 2, "id": "7f9e615b-d071-4728-b774-1d02f509c332", "metadata": { - "collapsed": true, - "jupyter": { - "outputs_hidden": true - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: geopandas in /opt/conda/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (0.10.2)\n", - "Requirement already satisfied: pygeos in /opt/conda/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (0.11.1)\n", - "Requirement already satisfied: ipyleaflet in /opt/conda/lib/python3.9/site-packages (from -r requirements.txt (line 3)) (0.14.0)\n", - "Requirement already satisfied: pyproj>=2.2.0 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (3.2.1)\n", - "Requirement already satisfied: pandas>=0.25.0 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (1.3.4)\n", - "Requirement already satisfied: shapely>=1.6 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (1.8.0)\n", - "Requirement already satisfied: fiona>=1.8 in /opt/conda/lib/python3.9/site-packages (from geopandas->-r requirements.txt (line 1)) (1.8.20)\n", - "Requirement already satisfied: numpy>=1.13 in /opt/conda/lib/python3.9/site-packages (from pygeos->-r requirements.txt (line 2)) (1.20.3)\n", - "Requirement already satisfied: ipywidgets<8,>=7.6.0 in /opt/conda/lib/python3.9/site-packages (from ipyleaflet->-r requirements.txt (line 3)) (7.6.5)\n", - "Requirement already satisfied: traittypes<3,>=0.2.1 in /opt/conda/lib/python3.9/site-packages (from ipyleaflet->-r requirements.txt (line 3)) (0.2.1)\n", - "Requirement already satisfied: attrs>=17 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (21.2.0)\n", - "Requirement already satisfied: munch in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (2.5.0)\n", - "Requirement already satisfied: setuptools in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (58.3.0)\n", - "Requirement already satisfied: six>=1.7 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (1.16.0)\n", - "Requirement already satisfied: click>=4.0 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (8.0.3)\n", - "Requirement already satisfied: certifi in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (2021.10.8)\n", - "Requirement already satisfied: click-plugins>=1.0 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (1.1.1)\n", - "Requirement already satisfied: cligj>=0.5 in /opt/conda/lib/python3.9/site-packages (from fiona>=1.8->geopandas->-r requirements.txt (line 1)) (0.7.2)\n", - "Requirement already satisfied: ipython>=4.0.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (7.29.0)\n", - "Requirement already satisfied: ipykernel>=4.5.1 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.4.2)\n", - "Requirement already satisfied: nbformat>=4.2.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (5.1.3)\n", - "Requirement already satisfied: ipython-genutils~=0.2.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.2.0)\n", - "Requirement already satisfied: traitlets>=4.3.1 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (5.1.1)\n", - "Requirement already satisfied: jupyterlab-widgets>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.0.2)\n", - "Requirement already satisfied: widgetsnbextension~=3.5.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (3.5.2)\n", - "Requirement already satisfied: python-dateutil>=2.7.3 in /opt/conda/lib/python3.9/site-packages (from pandas>=0.25.0->geopandas->-r requirements.txt (line 1)) (2.8.2)\n", - "Requirement already satisfied: pytz>=2017.3 in /opt/conda/lib/python3.9/site-packages (from pandas>=0.25.0->geopandas->-r requirements.txt (line 1)) (2021.3)\n", - "Requirement already satisfied: debugpy<2.0,>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.4.1)\n", - "Requirement already satisfied: tornado<7.0,>=4.2 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.1)\n", - "Requirement already satisfied: jupyter-client<8.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (7.0.6)\n", - "Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.1.3)\n", - "Requirement already satisfied: backcall in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.2.0)\n", - "Requirement already satisfied: jedi>=0.16 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.18.0)\n", - "Requirement already satisfied: decorator in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (5.1.0)\n", - "Requirement already satisfied: pexpect>4.3 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.8.0)\n", - "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (3.0.21)\n", - "Requirement already satisfied: pygments in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.10.0)\n", - "Requirement already satisfied: pickleshare in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.7.5)\n", - "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.1.2)\n", - "Requirement already satisfied: jupyter-core in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.9.1)\n", - "Requirement already satisfied: notebook>=4.4.1 in /opt/conda/lib/python3.9/site-packages (from widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.4.5)\n", - "Requirement already satisfied: parso<0.9.0,>=0.8.0 in /opt/conda/lib/python3.9/site-packages (from jedi>=0.16->ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.8.2)\n", - "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /opt/conda/lib/python3.9/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.17.3)\n", - "Requirement already satisfied: entrypoints in /opt/conda/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.3)\n", - "Requirement already satisfied: pyzmq>=13 in /opt/conda/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (22.3.0)\n", - "Requirement already satisfied: nest-asyncio>=1.5 in /opt/conda/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=4.5.1->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.5.1)\n", - "Requirement already satisfied: prometheus-client in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.12.0)\n", - "Requirement already satisfied: terminado>=0.8.3 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.12.1)\n", - "Requirement already satisfied: jinja2 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (3.0.2)\n", - "Requirement already satisfied: nbconvert in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (6.2.0)\n", - "Requirement already satisfied: Send2Trash>=1.5.0 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.8.0)\n", - "Requirement already satisfied: argon2-cffi in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (21.1.0)\n", - "Requirement already satisfied: ptyprocess>=0.5 in /opt/conda/lib/python3.9/site-packages (from pexpect>4.3->ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.7.0)\n", - "Requirement already satisfied: wcwidth in /opt/conda/lib/python3.9/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=4.0.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.2.5)\n", - "Requirement already satisfied: cffi>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.14.6)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.9/site-packages (from jinja2->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.0.1)\n", - "Requirement already satisfied: defusedxml in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.7.1)\n", - "Requirement already satisfied: testpath in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.5.0)\n", - "Requirement already satisfied: bleach in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (4.1.0)\n", - "Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.5.4)\n", - "Requirement already satisfied: mistune<2,>=0.8.1 in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.8.4)\n", - "Requirement already satisfied: jupyterlab-pygments in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.1.2)\n", - "Requirement already satisfied: pandocfilters>=1.4.1 in /opt/conda/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (1.5.0)\n", - "Requirement already satisfied: pycparser in /opt/conda/lib/python3.9/site-packages (from cffi>=1.0.0->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.20)\n", - "Requirement already satisfied: webencodings in /opt/conda/lib/python3.9/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (0.5.1)\n", - "Requirement already satisfied: packaging in /opt/conda/lib/python3.9/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (21.2)\n", - "Requirement already satisfied: pyparsing<3,>=2.0.2 in /opt/conda/lib/python3.9/site-packages (from packaging->bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets<8,>=7.6.0->ipyleaflet->-r requirements.txt (line 3)) (2.4.7)\n" - ] - } - ], + "outputs": [], "source": [ - "!pip install -r requirements.txt" + "# !pip install -r requirements.txt" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 162, "id": "4d53c57e-0777-4c0d-9dc6-4954c95ed307", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/opt/conda/lib/python3.9/site-packages/geopandas/_compat.py:111: UserWarning: The Shapely GEOS version (3.9.1-CAPI-1.14.2) is incompatible with the GEOS version PyGEOS was compiled with (3.10.0-CAPI-1.16.0). Conversions between both will be slow.\n", - " warnings.warn(\n" - ] - } - ], + "outputs": [], "source": [ "import calitp\n", "from calitp.tables import tbl\n", @@ -124,19 +37,20 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 163, "id": "e31ad027-1acc-44f8-bdd6-31f1b9b36a77", "metadata": {}, "outputs": [], "source": [ "bus_hqtc = gpd.read_parquet(f'{GCS_FILE_PATH}shape_hqta_dissolve.parquet')\n", "bus_hqtc = bus_hqtc[bus_hqtc['hq_transit_corr']]\n", - "bus_hqtc['hqta_type'] = 'hq_transit_corr'" + "bus_hqtc['hqta_type'] = 'hq_transit_corr'\n", + "bus_hqtc['route_type'] = '3'" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 164, "id": "bcbea24e-ab7e-400a-8813-6a477471c1d6", "metadata": {}, "outputs": [], @@ -147,62 +61,49 @@ }, { "cell_type": "code", - "execution_count": 5, - "id": "0e807584-dfb2-4385-b274-7276b0bc38d0", - "metadata": { - "collapsed": true, - "jupyter": { - "outputs_hidden": true - }, - "tags": [] - }, + "execution_count": 165, + "id": "6aec4721-0827-40f3-be60-0790916b0385", + "metadata": {}, "outputs": [ { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jovyan/data-analyses/high_quality_transit_areas/utilities.py:85: UserWarning: this is an initial implementation of Parquet/Feather file support and associated metadata. This is tracking version 0.1.0 of the metadata specification at https://github.com/geopandas/geo-arrow-spec\n", - "\n", - "This metadata specification does not yet make stability promises. We do not yet recommend using this in a production setting unless you are able to rewrite your Parquet/Feather files.\n", - "\n", - "To further ignore this warning, you can do: \n", - "import warnings; warnings.filterwarnings('ignore', message='.*initial implementation of Parquet.*')\n", - " gdf.to_parquet(f\"{name}.parquet\")\n" - ] + "data": { + "text/plain": [ + "Index(['calitp_itp_id', 'calitp_url_number', 'stop_id', 'stop_lat', 'stop_lon',\n", + " 'route_type', 'geometry', 'hqta_type'],\n", + " dtype='object')" + ] + }, + "execution_count": 165, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "geoparquet_gcs_export(bus_hqtc, 'bus_hqtc')" + "rail_ferry_brt_stops.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 166, + "id": "0e807584-dfb2-4385-b274-7276b0bc38d0", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# geoparquet_gcs_export(bus_hqtc, 'bus_hqtc')" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 167, "id": "3b9a9f5e-6371-4367-978c-c0be0e6d979f", "metadata": { - "collapsed": true, - "jupyter": { - "outputs_hidden": true - }, "tags": [] }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jovyan/data-analyses/high_quality_transit_areas/utilities.py:85: UserWarning: this is an initial implementation of Parquet/Feather file support and associated metadata. This is tracking version 0.1.0 of the metadata specification at https://github.com/geopandas/geo-arrow-spec\n", - "\n", - "This metadata specification does not yet make stability promises. We do not yet recommend using this in a production setting unless you are able to rewrite your Parquet/Feather files.\n", - "\n", - "To further ignore this warning, you can do: \n", - "import warnings; warnings.filterwarnings('ignore', message='.*initial implementation of Parquet.*')\n", - " gdf.to_parquet(f\"{name}.parquet\")\n" - ] - } - ], + "outputs": [], "source": [ - "geoparquet_gcs_export(rail_ferry_brt_stops, 'rail_ferry_brt_stops')" + "# geoparquet_gcs_export(rail_ferry_brt_stops, 'rail_ferry_brt_stops')" ] }, { @@ -245,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 168, "id": "441de95c-34c4-46bd-a95c-bfa0fd0338ea", "metadata": {}, "outputs": [ @@ -273,90 +174,86 @@ " hq_transit_corr\n", " shape_id\n", " geometry\n", - " level_0\n", " calitp_itp_id\n", " hqta_segment_id\n", - " n_trips\n", " segment_sequence\n", " stop_id\n", - " am_peak\n", - " pm_peak\n", + " am_max_trips\n", + " pm_max_trips\n", " hqta_type\n", + " route_type\n", " \n", " \n", " \n", " \n", - " 2464\n", + " 2256\n", " True\n", - " 0500\n", - " MULTIPOLYGON (((193308.696 -465893.120, 193308...\n", - " 0\n", - " 142\n", - " 2197551287\n", - " 134.0\n", + " 01582b61-5a02-4e6c-bd37-bad46bb036a9\n", + " POLYGON ((-133311.510 166655.910, -133353.419 ...\n", + " 48\n", + " 1937384376\n", " 0\n", - " 3977\n", - " 9.0\n", + " 12f4ecb6-c161-480e-8ec2-d7e3b63c7e38\n", + " 7.0\n", " 8.0\n", " hq_transit_corr\n", + " 3\n", " \n", " \n", - " 2466\n", + " 2257\n", " True\n", - " 10\n", - " MULTIPOLYGON (((170627.569 -429628.875, 170627...\n", + " 0500\n", + " POLYGON ((212373.929 -486798.063, 212402.264 -...\n", + " 142\n", + " 4126984225\n", " 1\n", - " 243\n", - " 2088216280\n", - " 64.0\n", - " 2\n", - " 604\n", - " 4.7\n", + " 4654\n", " 5.0\n", + " 7.0\n", " hq_transit_corr\n", + " 3\n", " \n", " \n", - " 2467\n", + " 2258\n", " True\n", - " 100706_SEPT21\n", - " MULTIPOLYGON (((149722.349 -435846.031, 149624...\n", + " 0843\n", + " MULTIPOLYGON (((200815.723 -472198.343, 200811...\n", + " 142\n", + " 1555422069\n", " 0\n", - " 182\n", - " 2368710740\n", - " 120.0\n", - " 1\n", - " 16374\n", + " 6679\n", + " 5.0\n", " 6.0\n", - " 8.0\n", " hq_transit_corr\n", + " 3\n", " \n", " \n", "\n", "" ], "text/plain": [ - " hq_transit_corr shape_id \\\n", - "2464 True 0500 \n", - "2466 True 10 \n", - "2467 True 100706_SEPT21 \n", + " hq_transit_corr shape_id \\\n", + "2256 True 01582b61-5a02-4e6c-bd37-bad46bb036a9 \n", + "2257 True 0500 \n", + "2258 True 0843 \n", "\n", - " geometry level_0 \\\n", - "2464 MULTIPOLYGON (((193308.696 -465893.120, 193308... 0 \n", - "2466 MULTIPOLYGON (((170627.569 -429628.875, 170627... 1 \n", - "2467 MULTIPOLYGON (((149722.349 -435846.031, 149624... 0 \n", + " geometry calitp_itp_id \\\n", + "2256 POLYGON ((-133311.510 166655.910, -133353.419 ... 48 \n", + "2257 POLYGON ((212373.929 -486798.063, 212402.264 -... 142 \n", + "2258 MULTIPOLYGON (((200815.723 -472198.343, 200811... 142 \n", "\n", - " calitp_itp_id hqta_segment_id n_trips segment_sequence stop_id \\\n", - "2464 142 2197551287 134.0 0 3977 \n", - "2466 243 2088216280 64.0 2 604 \n", - "2467 182 2368710740 120.0 1 16374 \n", + " hqta_segment_id segment_sequence stop_id \\\n", + "2256 1937384376 0 12f4ecb6-c161-480e-8ec2-d7e3b63c7e38 \n", + "2257 4126984225 1 4654 \n", + "2258 1555422069 0 6679 \n", "\n", - " am_peak pm_peak hqta_type \n", - "2464 9.0 8.0 hq_transit_corr \n", - "2466 4.7 5.0 hq_transit_corr \n", - "2467 6.0 8.0 hq_transit_corr " + " am_max_trips pm_max_trips hqta_type route_type \n", + "2256 7.0 8.0 hq_transit_corr 3 \n", + "2257 5.0 7.0 hq_transit_corr 3 \n", + "2258 5.0 6.0 hq_transit_corr 3 " ] }, - "execution_count": 9, + "execution_count": 168, "metadata": {}, "output_type": "execute_result" } @@ -367,7 +264,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 169, "id": "f104e680-a949-4e07-a4dd-19950207c66f", "metadata": {}, "outputs": [], @@ -389,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 170, "id": "96caf70f-e497-4df4-9b1a-20b54f7b7f83", "metadata": {}, "outputs": [], @@ -399,7 +296,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 171, "id": "cdb9023e-8397-4eed-b829-0ab22ee26580", "metadata": {}, "outputs": [], @@ -409,7 +306,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 172, "id": "a54925c8-cb64-452f-b8ac-18407ed3f9d6", "metadata": {}, "outputs": [], @@ -419,17 +316,17 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 173, "id": "c3f748fa-861d-4d7c-b005-480d6ecc30a2", "metadata": {}, "outputs": [], "source": [ - "major_bus = gpd.read_parquet(f'{GCS_FILE_PATH}major_bus_stops_working.parquet')" + "# major_bus = gpd.read_parquet(f'{GCS_FILE_PATH}major_bus_stops_working.parquet')" ] }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 174, "id": "ca09eb4e-97b4-48b6-ba21-542ac35c8ceb", "metadata": {}, "outputs": [], @@ -448,17 +345,17 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 175, "id": "82e5d819-63dc-4ba3-a9f9-c314f5a4ca33", "metadata": {}, "outputs": [], "source": [ - "major_bus['geometry'] = major_bus.geometry.apply(drop_big_areas)" + "# major_bus['geometry'] = major_bus.geometry.apply(drop_big_areas)" ] }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 176, "id": "6273ed98-b5a2-4e83-bfac-9f487f8c6142", "metadata": {}, "outputs": [], @@ -479,21 +376,59 @@ }, { "cell_type": "code", - "execution_count": 40, - "id": "c35ed21e-d6e0-42cf-8bd5-e4792d5d3c14", + "execution_count": 177, + "id": "280f79d2-ed38-419d-be89-653167b1efec", "metadata": {}, "outputs": [], "source": [ - "major_bus = major_bus.dropna(subset=['geometry'])" + "# major_bus = major_bus.dropna(subset=['geometry'])\n", + "\n", + "# major_bus.apply(explode_geoms, axis=1)\n", + "\n", + "# row_per_stop = row_per_stop.reset_index(drop=True)\n", + "\n", + "# row_per_stop = row_per_stop[['calitp_itp_id', 'stop_id', 'geometry']]\n", + "\n", + "# row_per_stop['hqta_type'] = 'major_transit_stop'\n", + "\n", + "# row_per_stop = row_per_stop.set_crs('EPSG:6414')" ] }, { "cell_type": "code", - "execution_count": 41, - "id": "2df43e17-9ca0-4c46-b6a1-92d77ec98d3a", - "metadata": { - "tags": [] - }, + "execution_count": 178, + "id": "d01200cc-cda2-4635-af68-3b8448e70b5a", + "metadata": {}, + "outputs": [], + "source": [ + "# row_per_stop.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 179, + "id": "5bbfaa07-f16c-46a9-ae5e-338a5b7f5d8b", + "metadata": {}, + "outputs": [], + "source": [ + "# geoparquet_gcs_export(row_per_stop, 'major_bus_stops')" + ] + }, + { + "cell_type": "code", + "execution_count": 180, + "id": "87dbcdc7-79f0-48e4-91d4-647cdb087cf5", + "metadata": {}, + "outputs": [], + "source": [ + "major_bus_stops = gpd.read_parquet(f'{GCS_FILE_PATH}major_bus_stops.parquet')" + ] + }, + { + "cell_type": "code", + "execution_count": 181, + "id": "e3e8c306-a89f-438f-8f0e-5e165e257cb6", + "metadata": {}, "outputs": [ { "data": { @@ -516,287 +451,88 @@ " \n", " \n", " \n", - " hq_transit_corr\n", - " shape_id\n", - " geometry\n", - " level_0\n", " calitp_itp_id\n", - " hqta_segment_id\n", - " n_trips\n", - " segment_sequence\n", " stop_id\n", - " am_peak\n", - " pm_peak\n", + " geometry\n", " hqta_type\n", " \n", " \n", " \n", " \n", - " 2464\n", - " True\n", - " 0500\n", - " POINT (193061.249 -465491.440)\n", - " 0\n", + " 0\n", " 142\n", - " 2197551287\n", - " 134.0\n", - " 0\n", " 3977\n", - " 9.0\n", - " 8.0\n", - " hq_transit_corr\n", - " \n", - " \n", - " 2467\n", - " True\n", - " 100706_SEPT21\n", - " POINT (149243.534 -435856.085)\n", - " 0\n", - " 182\n", - " 2368710740\n", - " 120.0\n", - " 1\n", - " 16374\n", - " 6.0\n", - " 8.0\n", - " hq_transit_corr\n", - " \n", - " \n", - " 2468\n", - " True\n", - " 100708_SEPT21\n", - " POINT (159441.767 -444289.585)\n", - " 3\n", - " 182\n", - " 2883785450\n", - " 72.0\n", - " 3\n", - " 9785\n", - " 4.7\n", - " 4.7\n", - " hq_transit_corr\n", - " \n", - " \n", - " 2471\n", - " True\n", - " 1020067_SEPT21\n", - " POINT (150511.825 -447354.169)\n", - " 3\n", - " 182\n", - " 2238923216\n", - " 115.0\n", - " 4\n", - " 11283\n", - " 8.0\n", - " 8.0\n", - " hq_transit_corr\n", - " \n", - " \n", - " 2475\n", - " True\n", - " 103717\n", - " POINT (-178950.630 -71003.248)\n", - " 1\n", - " 294\n", - " 2280977661\n", - " 136.0\n", - " 3\n", - " 480\n", - " 7.0\n", - " 8.0\n", - " hq_transit_corr\n", - " \n", - " \n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " \n", - " \n", - " 3231\n", - " True\n", - " shp-73-01\n", - " POINT (-194726.607 -31504.765)\n", - " 0\n", - " 4\n", - " 1652690359\n", - " 220.0\n", - " 0\n", - " 3708\n", - " 9.3\n", - " 11.7\n", - " hq_transit_corr\n", - " \n", - " \n", - " 3232\n", - " True\n", - " shp-73-51\n", - " POINT (-194726.607 -31504.765)\n", - " 0\n", - " 4\n", - " 1682558812\n", - " 238.0\n", - " 0\n", - " 2712\n", - " 13.3\n", - " 10.0\n", - " hq_transit_corr\n", - " \n", - " \n", - " 3236\n", - " True\n", - " shp-88-07\n", - " POINT (-200443.266 -13810.682)\n", - " 1\n", - " 4\n", - " 3310950755\n", - " 83.0\n", - " 1\n", - " 2026\n", - " 4.7\n", - " 5.0\n", - " hq_transit_corr\n", + " POINT (199058.382 -471125.032)\n", + " major_transit_stop\n", " \n", " \n", - " 3238\n", - " True\n", - " shp-97-57\n", - " POINT (-187275.985 -33268.849)\n", - " 0\n", - " 4\n", - " 4254707562\n", - " 80.0\n", - " 0\n", - " 4320\n", - " 4.3\n", - " 4.7\n", - " hq_transit_corr\n", + " 1\n", + " 142\n", + " 3977\n", + " POINT (198531.592 -471368.189)\n", + " major_transit_stop\n", " \n", " \n", - " 3239\n", - " True\n", - " shp-99-08\n", - " POINT (-178261.436 -45851.507)\n", - " 0\n", - " 4\n", - " 3287994159\n", - " 142.0\n", - " 0\n", - " 6243\n", - " 7.7\n", - " 8.0\n", - " hq_transit_corr\n", + " 2\n", + " 142\n", + " 3977\n", + " POINT (193068.693 -465847.391)\n", + " major_transit_stop\n", " \n", " \n", "\n", - "

349 rows × 12 columns

\n", "" ], "text/plain": [ - " hq_transit_corr shape_id geometry \\\n", - "2464 True 0500 POINT (193061.249 -465491.440) \n", - "2467 True 100706_SEPT21 POINT (149243.534 -435856.085) \n", - "2468 True 100708_SEPT21 POINT (159441.767 -444289.585) \n", - "2471 True 1020067_SEPT21 POINT (150511.825 -447354.169) \n", - "2475 True 103717 POINT (-178950.630 -71003.248) \n", - "... ... ... ... \n", - "3231 True shp-73-01 POINT (-194726.607 -31504.765) \n", - "3232 True shp-73-51 POINT (-194726.607 -31504.765) \n", - "3236 True shp-88-07 POINT (-200443.266 -13810.682) \n", - "3238 True shp-97-57 POINT (-187275.985 -33268.849) \n", - "3239 True shp-99-08 POINT (-178261.436 -45851.507) \n", - "\n", - " level_0 calitp_itp_id hqta_segment_id n_trips segment_sequence \\\n", - "2464 0 142 2197551287 134.0 0 \n", - "2467 0 182 2368710740 120.0 1 \n", - "2468 3 182 2883785450 72.0 3 \n", - "2471 3 182 2238923216 115.0 4 \n", - "2475 1 294 2280977661 136.0 3 \n", - "... ... ... ... ... ... \n", - "3231 0 4 1652690359 220.0 0 \n", - "3232 0 4 1682558812 238.0 0 \n", - "3236 1 4 3310950755 83.0 1 \n", - "3238 0 4 4254707562 80.0 0 \n", - "3239 0 4 3287994159 142.0 0 \n", - "\n", - " stop_id am_peak pm_peak hqta_type \n", - "2464 3977 9.0 8.0 hq_transit_corr \n", - "2467 16374 6.0 8.0 hq_transit_corr \n", - "2468 9785 4.7 4.7 hq_transit_corr \n", - "2471 11283 8.0 8.0 hq_transit_corr \n", - "2475 480 7.0 8.0 hq_transit_corr \n", - "... ... ... ... ... \n", - "3231 3708 9.3 11.7 hq_transit_corr \n", - "3232 2712 13.3 10.0 hq_transit_corr \n", - "3236 2026 4.7 5.0 hq_transit_corr \n", - "3238 4320 4.3 4.7 hq_transit_corr \n", - "3239 6243 7.7 8.0 hq_transit_corr \n", - "\n", - "[349 rows x 12 columns]" + " calitp_itp_id stop_id geometry hqta_type\n", + "0 142 3977 POINT (199058.382 -471125.032) major_transit_stop\n", + "1 142 3977 POINT (198531.592 -471368.189) major_transit_stop\n", + "2 142 3977 POINT (193068.693 -465847.391) major_transit_stop" ] }, - "execution_count": 41, + "execution_count": 181, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "major_bus.apply(explode_geoms, axis=1)" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "id": "6ab04e63-f673-48d4-bf1a-d01d203f5b33", - "metadata": {}, - "outputs": [], - "source": [ - "row_per_stop = row_per_stop.reset_index(drop=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "id": "92d2df98-49d9-4786-bd53-df2ddc107354", - "metadata": {}, - "outputs": [], - "source": [ - "row_per_stop = row_per_stop[['calitp_itp_id', 'geometry']]" + "major_bus_stops.head(3)" ] }, { "cell_type": "code", - "execution_count": 44, - "id": "faaa147d-ae1e-4b9b-a7a2-ff462a3c66fd", + "execution_count": 182, + "id": "24daf28c-943a-4a9f-871c-e11b5d761595", "metadata": {}, "outputs": [], "source": [ - "row_per_stop['hqta_type'] = 'major_transit_stop'" + "tbl_stops = (tbl.views.gtfs_schedule_fact_daily_feed_stops()\n", + " >> filter(_.date == '2021-12-01')\n", + " >> filter(_.calitp_extracted_at < '2021-12-01')\n", + " >> filter(_.calitp_deleted_at > '2021-12-01')\n", + " >> select(_.stop_key)\n", + " >> inner_join(_, tbl.views.gtfs_schedule_dim_stops(), on = 'stop_key')\n", + " >> select(_.stop_id, _.stop_lat, _.stop_lon, _.calitp_itp_id)\n", + " >> collect()\n", + ")" ] }, { "cell_type": "code", - "execution_count": 45, - "id": "3e574e12-8017-4867-9230-8fa891e914bb", + "execution_count": 183, + "id": "cddf70f5-cca1-4896-9f52-1ea5004278e5", "metadata": {}, "outputs": [], "source": [ - "row_per_stop = row_per_stop.set_crs('EPSG:6414')" + "tbl_stops = gpd.GeoDataFrame(tbl_stops,\n", + " geometry = gpd.points_from_xy(tbl_stops.stop_lon, tbl_stops.stop_lat),\n", + " crs = 'EPSG:4326').to_crs('EPSG:6414') ## https://epsg.io/6414 (meters)" ] }, { "cell_type": "code", - "execution_count": 46, - "id": "d01200cc-cda2-4635-af68-3b8448e70b5a", + "execution_count": 184, + "id": "27ec75fc-e017-4f98-96f8-94d8d6ca479e", "metadata": {}, "outputs": [ { @@ -820,28 +556,1085 @@ " \n", " \n", " \n", + " stop_id\n", + " stop_lat\n", + " stop_lon\n", + " calitp_itp_id\n", + " stop_id\n", + " stop_lat\n", + " stop_lon\n", " calitp_itp_id\n", " geometry\n", - " hqta_type\n", " \n", " \n", " \n", " \n", " 0\n", - " 142\n", - " POINT (199058.382 -471125.032)\n", - " major_transit_stop\n", + " 5090\n", + " 36.080261\n", + " -119.021684\n", + " 256\n", + " POINT (87996.619 -214744.271)\n", " \n", " \n", " 1\n", - " 142\n", - " POINT (198531.592 -471368.189)\n", - " major_transit_stop\n", + " 8050\n", + " 36.061094\n", + " -118.994880\n", + " 256\n", + " POINT (90430.048 -216848.624)\n", " \n", " \n", " 2\n", - " 142\n", - " POINT (193068.693 -465847.391)\n", + " 1100\n", + " 36.073048\n", + " -119.020918\n", + " 256\n", + " POINT (88073.792 -215544.973)\n", + " \n", + " \n", + "\n", + "" + ], + "text/plain": [ + " stop_id stop_lat stop_lon calitp_itp_id geometry\n", + "0 5090 36.080261 -119.021684 256 POINT (87996.619 -214744.271)\n", + "1 8050 36.061094 -118.994880 256 POINT (90430.048 -216848.624)\n", + "2 1100 36.073048 -119.020918 256 POINT (88073.792 -215544.973)" + ] + }, + "execution_count": 184, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tbl_stops.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 185, + "id": "d5a65203-2245-4ea4-94d3-71685a00c929", + "metadata": {}, + "outputs": [], + "source": [ + "to_join = major_bus_stops[['calitp_itp_id']].astype({'calitp_itp_id': 'int64'})" + ] + }, + { + "cell_type": "code", + "execution_count": 186, + "id": "19f9b7dd-1b2b-4c7a-9ba9-3e1e1e9b46be", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "tbl_stops_major = (tbl_stops\n", + " >> inner_join(_, to_join, on=['calitp_itp_id'])\n", + " >> distinct(_.calitp_itp_id, _.stop_id, _keep_all=True)\n", + " )\n" + ] + }, + { + "cell_type": "code", + "execution_count": 187, + "id": "5410b54c-930f-4d88-982a-4275a90334d4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
stop_idstop_latstop_loncalitp_itp_idgeometry
0397137.976371-122.3196634POINT (-203473.763 -1956.750)
1205037.789595-122.2458004POINT (-197487.747 -22870.228)
2344537.767420-122.1963754POINT (-193199.376 -25436.510)
\n", + "
" + ], + "text/plain": [ + " stop_id stop_lat stop_lon calitp_itp_id \\\n", + "0 3971 37.976371 -122.319663 4 \n", + "1 2050 37.789595 -122.245800 4 \n", + "2 3445 37.767420 -122.196375 4 \n", + "\n", + " geometry \n", + "0 POINT (-203473.763 -1956.750) \n", + "1 POINT (-197487.747 -22870.228) \n", + "2 POINT (-193199.376 -25436.510) " + ] + }, + "execution_count": 187, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tbl_stops_major.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 188, + "id": "9a9987a0-74c2-4018-99d6-bc68ecbb292a", + "metadata": {}, + "outputs": [], + "source": [ + "tbl_stops_major.geometry = tbl_stops_major.buffer(100)" + ] + }, + { + "cell_type": "code", + "execution_count": 189, + "id": "ee7ff27d-6ffc-4458-bd95-5aa5c8a9a57e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
stop_idstop_latstop_loncalitp_itp_idgeometry
0397137.976371-122.3196634POLYGON ((-203373.763 -1956.750, -203374.244 -...
1205037.789595-122.2458004POLYGON ((-197387.747 -22870.228, -197388.229 ...
2344537.767420-122.1963754POLYGON ((-193099.376 -25436.510, -193099.857 ...
\n", + "
" + ], + "text/plain": [ + " stop_id stop_lat stop_lon calitp_itp_id \\\n", + "0 3971 37.976371 -122.319663 4 \n", + "1 2050 37.789595 -122.245800 4 \n", + "2 3445 37.767420 -122.196375 4 \n", + "\n", + " geometry \n", + "0 POLYGON ((-203373.763 -1956.750, -203374.244 -... \n", + "1 POLYGON ((-197387.747 -22870.228, -197388.229 ... \n", + "2 POLYGON ((-193099.376 -25436.510, -193099.857 ... " + ] + }, + "execution_count": 189, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tbl_stops_major.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 190, + "id": "1ac15d0a-1aeb-48c4-9acf-92b7642b6fcd", + "metadata": {}, + "outputs": [], + "source": [ + "drop_id = major_bus_stops.drop(columns=['stop_id'])" + ] + }, + { + "cell_type": "code", + "execution_count": 191, + "id": "e1d0d729-4931-4020-bfd6-4c15818caff0", + "metadata": {}, + "outputs": [], + "source": [ + "spatial_stops_major = tbl_stops_major.sjoin(drop_id, how='inner', predicate='contains')" + ] + }, + { + "cell_type": "code", + "execution_count": 192, + "id": "b593d95a-308f-4635-9ce5-f24bbdd164e6", + "metadata": {}, + "outputs": [], + "source": [ + "new_major_stops = spatial_stops_major.drop_duplicates(subset=['stop_id', 'calitp_itp_id_left', 'calitp_itp_id_right'])" + ] + }, + { + "cell_type": "code", + "execution_count": 193, + "id": "46241013-0529-40c7-a8d9-3002637a4240", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/opt/conda/lib/python3.9/site-packages/geopandas/geodataframe.py:1351: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame.\n", + "Try using .loc[row_indexer,col_indexer] = value instead\n", + "\n", + "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", + " super().__setitem__(key, value)\n" + ] + } + ], + "source": [ + "new_major_stops.geometry = new_major_stops.centroid" + ] + }, + { + "cell_type": "code", + "execution_count": 194, + "id": "ed5c5734-7ede-4211-a61b-f22eec81686a", + "metadata": {}, + "outputs": [], + "source": [ + "# map_hqta(new_major_stops)" + ] + }, + { + "cell_type": "markdown", + "id": "99a33ab8-c664-4671-89ef-54cdff7462f2", + "metadata": {}, + "source": [ + "### Bus Corridors to Stops Along Corridor" + ] + }, + { + "cell_type": "code", + "execution_count": 195, + "id": "6943606a-d815-49c6-aa43-a7ab27285939", + "metadata": {}, + "outputs": [], + "source": [ + "tbl_stops_corridors = tbl_stops" + ] + }, + { + "cell_type": "code", + "execution_count": 196, + "id": "bf2f1177-b087-416c-8ae4-3f3f3569da55", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
stop_idstop_latstop_loncalitp_itp_idgeometry
0509036.080261-119.021684256POINT (87996.619 -214744.271)
1805036.061094-118.994880256POINT (90430.048 -216848.624)
2110036.073048-119.020918256POINT (88073.792 -215544.973)
\n", + "
" + ], + "text/plain": [ + " stop_id stop_lat stop_lon calitp_itp_id geometry\n", + "0 5090 36.080261 -119.021684 256 POINT (87996.619 -214744.271)\n", + "1 8050 36.061094 -118.994880 256 POINT (90430.048 -216848.624)\n", + "2 1100 36.073048 -119.020918 256 POINT (88073.792 -215544.973)" + ] + }, + "execution_count": 196, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tbl_stops_corridors.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 197, + "id": "eda55a78-d4c5-47cc-8012-ac2d1fa4a92f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idstop_idhqta_typegeometry
22564812f4ecb6-c161-480e-8ec2-d7e3b63c7e38hq_corridor_busPOLYGON ((-133311.510 166655.910, -133353.419 ...
22571424654hq_corridor_busPOLYGON ((212373.929 -486798.063, 212402.264 -...
22581426679hq_corridor_busMULTIPOLYGON (((200815.723 -472198.343, 200811...
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id stop_id hqta_type \\\n", + "2256 48 12f4ecb6-c161-480e-8ec2-d7e3b63c7e38 hq_corridor_bus \n", + "2257 142 4654 hq_corridor_bus \n", + "2258 142 6679 hq_corridor_bus \n", + "\n", + " geometry \n", + "2256 POLYGON ((-133311.510 166655.910, -133353.419 ... \n", + "2257 POLYGON ((212373.929 -486798.063, 212402.264 -... \n", + "2258 MULTIPOLYGON (((200815.723 -472198.343, 200811... " + ] + }, + "execution_count": 197, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bus_hqtc_extract.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 198, + "id": "c161a6c5-bd29-4f0e-aaa2-f83731af42d4", + "metadata": {}, + "outputs": [], + "source": [ + "stops_in_corridor = tbl_stops_corridors.clip(bus_hqtc_extract)" + ] + }, + { + "cell_type": "code", + "execution_count": 199, + "id": "83da99fb-4d2c-438b-bf24-65ce726fba0a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Int64Index: 32894 entries, 26531 to 121250\n", + "Data columns (total 5 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 stop_id 32894 non-null object \n", + " 1 stop_lat 32894 non-null float64 \n", + " 2 stop_lon 32894 non-null float64 \n", + " 3 calitp_itp_id 32894 non-null int64 \n", + " 4 geometry 32894 non-null geometry\n", + "dtypes: float64(2), geometry(1), int64(1), object(1)\n", + "memory usage: 1.5+ MB\n" + ] + } + ], + "source": [ + "stops_in_corridor.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 200, + "id": "82657639-7ad8-43e2-9050-7b49b0da0799", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Int64Index: 32009 entries, 26531 to 121250\n", + "Data columns (total 5 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 stop_id 32009 non-null object \n", + " 1 stop_lat 32009 non-null float64 \n", + " 2 stop_lon 32009 non-null float64 \n", + " 3 calitp_itp_id 32009 non-null int64 \n", + " 4 geometry 32009 non-null geometry\n", + "dtypes: float64(2), geometry(1), int64(1), object(1)\n", + "memory usage: 1.5+ MB\n" + ] + } + ], + "source": [ + "stops_in_corridor.drop_duplicates(subset = ['stop_id', 'calitp_itp_id']).info()" + ] + }, + { + "cell_type": "code", + "execution_count": 201, + "id": "7fbca026-79dc-4249-a6fb-9ee436a422cc", + "metadata": {}, + "outputs": [], + "source": [ + "# map_hqta(bus_hqtc_extract)" + ] + }, + { + "cell_type": "code", + "execution_count": 202, + "id": "d10d08e6-2166-4d74-9b21-40181da5f19e", + "metadata": {}, + "outputs": [], + "source": [ + "# map_hqta(stops_in_corridor)" + ] + }, + { + "cell_type": "markdown", + "id": "f1ac0f78-6b99-4079-8c26-ca875367f6a8", + "metadata": {}, + "source": [ + "#### Definitions and Output:\n", + "\n", + "* hqta_type: major_transit_stop\n", + "* stop_id: one stop id... (not ideal, but oh well)\n", + "* geometry: .buffer(700)?\n", + "* _can alway pull more info spatially_" + ] + }, + { + "cell_type": "markdown", + "id": "03d81f0e-da43-4116-ae9b-b094b1466f2b", + "metadata": {}, + "source": [ + "## Unbuffered Export" + ] + }, + { + "cell_type": "markdown", + "id": "403c2790-2f47-4b3f-9740-443020721a0b", + "metadata": {}, + "source": [ + "Thank you for this data. It would be useful for us to get the HQTC stops as a point data file, not a polygon. Also, if you could differentiate between train, bus, BRT, and ferry stop that would be immensely helpful.\n", + "\n", + "Let me know if it is possible to get the data in this format. " + ] + }, + { + "cell_type": "markdown", + "id": "baa2a7f4-5212-4911-9e6e-1e9bfc2f1d59", + "metadata": {}, + "source": [ + "#### Major Transit Stops (bus intersections)" + ] + }, + { + "cell_type": "code", + "execution_count": 203, + "id": "a4188f4e-5b5f-44d6-b3be-e8ed70fd8e64", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
stop_idstop_latstop_loncalitp_itp_id_leftgeometryindex_rightcalitp_itp_id_righthqta_type
1205037.789595-122.2458004POINT (-197487.747 -22870.228)18734major_transit_stop
661616037.789312-122.2457844POINT (-197487.086 -22901.713)18734major_transit_stop
868604437.789646-122.2461174POINT (-197515.484 -22863.900)18734major_transit_stop
\n", + "
" + ], + "text/plain": [ + " stop_id stop_lat stop_lon calitp_itp_id_left \\\n", + "1 2050 37.789595 -122.245800 4 \n", + "661 6160 37.789312 -122.245784 4 \n", + "868 6044 37.789646 -122.246117 4 \n", + "\n", + " geometry index_right calitp_itp_id_right \\\n", + "1 POINT (-197487.747 -22870.228) 1873 4 \n", + "661 POINT (-197487.086 -22901.713) 1873 4 \n", + "868 POINT (-197515.484 -22863.900) 1873 4 \n", + "\n", + " hqta_type \n", + "1 major_transit_stop \n", + "661 major_transit_stop \n", + "868 major_transit_stop " + ] + }, + "execution_count": 203, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "new_major_stops.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 204, + "id": "c5a8d5cb-fd72-4dbf-85bb-a76996d567eb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idstop_idcalitp_itp_id_2hqta_typegeometry
1420504major_stop_busPOINT (-197487.747 -22870.228)
661461604major_stop_busPOINT (-197487.086 -22901.713)
868460444major_stop_busPOINT (-197515.484 -22863.900)
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id stop_id calitp_itp_id_2 hqta_type \\\n", + "1 4 2050 4 major_stop_bus \n", + "661 4 6160 4 major_stop_bus \n", + "868 4 6044 4 major_stop_bus \n", + "\n", + " geometry \n", + "1 POINT (-197487.747 -22870.228) \n", + "661 POINT (-197487.086 -22901.713) \n", + "868 POINT (-197515.484 -22863.900) " + ] + }, + "execution_count": 204, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "new_major_bus_extract = new_major_stops >> select(_.calitp_itp_id == _.calitp_itp_id_left, _.stop_id,\n", + " _.calitp_itp_id_2 == _.calitp_itp_id_right, _.hqta_type, _.geometry\n", + " )\n", + "new_major_bus_extract['hqta_type'] = 'major_stop_bus'\n", + "new_major_bus_extract.head(3)" + ] + }, + { + "cell_type": "markdown", + "id": "e9a0e81f-b16b-4fab-82e6-f7eb84999ee9", + "metadata": {}, + "source": [ + "#### Stops Along HQ Transit Corridors (bus)" + ] + }, + { + "cell_type": "code", + "execution_count": 205, + "id": "644055ed-ab86-4e07-80fb-0c17a457b8f4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
stop_idstop_latstop_loncalitp_itp_idgeometry
2653126234.420949-119.703600293POINT (27236.798 -399421.201)
66308S8034.421013-119.703516169POINT (27244.495 -399414.075)
2677611334.420955-119.670648293POINT (30264.810 -399410.543)
\n", + "
" + ], + "text/plain": [ + " stop_id stop_lat stop_lon calitp_itp_id \\\n", + "26531 262 34.420949 -119.703600 293 \n", + "66308 S80 34.421013 -119.703516 169 \n", + "26776 113 34.420955 -119.670648 293 \n", + "\n", + " geometry \n", + "26531 POINT (27236.798 -399421.201) \n", + "66308 POINT (27244.495 -399414.075) \n", + "26776 POINT (30264.810 -399410.543) " + ] + }, + "execution_count": 205, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_in_corridor.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 206, + "id": "e3fe89fe-f38c-4209-80da-b1a7ec950933", + "metadata": {}, + "outputs": [], + "source": [ + "stops_extract = stops_in_corridor >> select(_.calitp_itp_id, _.stop_id, _.geometry)" + ] + }, + { + "cell_type": "code", + "execution_count": 207, + "id": "62591143-ce91-408a-86a7-67d993a64205", + "metadata": {}, + "outputs": [], + "source": [ + "stops_extract['hqta_type'] = 'hq_corridor_bus'" + ] + }, + { + "cell_type": "code", + "execution_count": 208, + "id": "283ddc23-5a5f-4606-ab30-72341ee890cb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idstop_idgeometryhqta_type
26531293262POINT (27236.798 -399421.201)hq_corridor_bus
66308169S80POINT (27244.495 -399414.075)hq_corridor_bus
26776293113POINT (30264.810 -399410.543)hq_corridor_bus
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id stop_id geometry hqta_type\n", + "26531 293 262 POINT (27236.798 -399421.201) hq_corridor_bus\n", + "66308 169 S80 POINT (27244.495 -399414.075) hq_corridor_bus\n", + "26776 293 113 POINT (30264.810 -399410.543) hq_corridor_bus" + ] + }, + "execution_count": 208, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_extract.head(3)" + ] + }, + { + "cell_type": "markdown", + "id": "3d90eef5-3b4d-4c6a-96c9-e40a2855a260", + "metadata": {}, + "source": [ + "#### Major Transit Stops (rail/ferry/brt)" + ] + }, + { + "cell_type": "code", + "execution_count": 209, + "id": "5138b1e6-4c99-4ff1-b672-89d5f5a484e2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -849,84 +1642,524 @@ "" ], "text/plain": [ - " calitp_itp_id geometry hqta_type\n", - "0 142 POINT (199058.382 -471125.032) major_transit_stop\n", - "1 142 POINT (198531.592 -471368.189) major_transit_stop\n", - "2 142 POINT (193068.693 -465847.391) major_transit_stop" + " calitp_itp_id calitp_url_number stop_id stop_lat stop_lon \\\n", + "1066 182 1 80101 33.768071 -118.192921 \n", + "1078 182 1 80153 33.768740 -118.189362 \n", + "1076 182 1 80102 33.772258 -118.193700 \n", + "\n", + " route_type geometry hqta_type \n", + "1066 0 POINT (167426.752 -470294.073) major_transit_stop \n", + "1078 0 POINT (167755.039 -470213.608) major_transit_stop \n", + "1076 0 POINT (167345.741 -469831.223) major_transit_stop " + ] + }, + "execution_count": 209, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rail_ferry_brt_stops.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 210, + "id": "8a269cf5-fb38-467f-b31d-8c98c2aed684", + "metadata": {}, + "outputs": [], + "source": [ + "rail_ferry_brt_extract = rail_ferry_brt_stops >> select(_.calitp_itp_id == _.calitp_itp_id, _.stop_id,\n", + " _.hqta_type, _.route_type, _.geometry\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 211, + "id": "154b935a-5c1b-48d9-a44b-d276ade8b4ae", + "metadata": {}, + "outputs": [], + "source": [ + "rail_ferry_brt_extract = (rail_ferry_brt_extract\n", + " >> mutate(\n", + " hqta_type = case_when({\n", + " _.route_type.isin(['0', '1', '2']): 'major_stop_rail',\n", + " _.route_type == '3': 'major_stop_brt',\n", + " _.route_type == '4': 'major_stop_ferry'\n", + " })\n", + " )\n", + " >> select(-_.route_type)\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 212, + "id": "795f12d4-f881-4d72-adf2-69a4276084e9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "
calitp_itp_idcalitp_url_numberstop_idstop_latstop_lonroute_typegeometryhqta_type
106618218010133.768071-118.1929210POINT (167426.752 -470294.073)major_transit_stop
107818218015333.768740-118.1893620POINT (167755.039 -470213.608)major_transit_stop
107618218010233.772258-118.1937000POINT (167345.741 -469831.223)major_transit_stop
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idstop_idhqta_typegeometry
106618280101major_stop_railPOINT (167426.752 -470294.073)
107818280153major_stop_railPOINT (167755.039 -470213.608)
107618280102major_stop_railPOINT (167345.741 -469831.223)
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id stop_id hqta_type geometry\n", + "1066 182 80101 major_stop_rail POINT (167426.752 -470294.073)\n", + "1078 182 80153 major_stop_rail POINT (167755.039 -470213.608)\n", + "1076 182 80102 major_stop_rail POINT (167345.741 -469831.223)" + ] + }, + "execution_count": 212, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rail_ferry_brt_extract.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 213, + "id": "45f7684d-af37-4e66-bfec-e5e5d4b1d2c4", + "metadata": {}, + "outputs": [], + "source": [ + "points_combined = new_major_bus_extract.append(stops_extract).append(rail_ferry_brt_extract)" + ] + }, + { + "cell_type": "code", + "execution_count": 214, + "id": "f74db8b5-c1c2-4f68-88d8-89964d2a7179", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "calitp_itp_id int64\n", + "stop_id object\n", + "calitp_itp_id_2 object\n", + "hqta_type object\n", + "geometry geometry\n", + "dtype: object" + ] + }, + "execution_count": 214, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "points_combined.dtypes" + ] + }, + { + "cell_type": "code", + "execution_count": 215, + "id": "c767a0e4-e8c5-4967-b223-c982717de70c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idstop_idcalitp_itp_id_2hqta_typegeometry
1420504major_stop_busPOINT (-197487.747 -22870.228)
661461604major_stop_busPOINT (-197487.086 -22901.713)
868460444major_stop_busPOINT (-197515.484 -22863.900)
4378461614major_stop_busPOINT (-197544.479 -22958.955)
6453074major_stop_busPOINT (-189006.213 -28181.062)
..................
42328295NaNmajor_stop_brtPOINT (246407.338 -422724.364)
172328288NaNmajor_stop_brtPOINT (243453.358 -421760.464)
996323165NaNmajor_stop_railPOINT (172732.681 -389214.320)
34213VRVNaNmajor_stop_railPOINT (248354.060 -383016.649)
994323163NaNmajor_stop_railPOINT (172437.092 -378906.434)
\n", + "

37473 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " calitp_itp_id stop_id calitp_itp_id_2 hqta_type \\\n", + "1 4 2050 4 major_stop_bus \n", + "661 4 6160 4 major_stop_bus \n", + "868 4 6044 4 major_stop_bus \n", + "4378 4 6161 4 major_stop_bus \n", + "6 4 5307 4 major_stop_bus \n", + "... ... ... ... ... \n", + "4 232 8295 NaN major_stop_brt \n", + "17 232 8288 NaN major_stop_brt \n", + "996 323 165 NaN major_stop_rail \n", + "342 13 VRV NaN major_stop_rail \n", + "994 323 163 NaN major_stop_rail \n", + "\n", + " geometry \n", + "1 POINT (-197487.747 -22870.228) \n", + "661 POINT (-197487.086 -22901.713) \n", + "868 POINT (-197515.484 -22863.900) \n", + "4378 POINT (-197544.479 -22958.955) \n", + "6 POINT (-189006.213 -28181.062) \n", + "... ... \n", + "4 POINT (246407.338 -422724.364) \n", + "17 POINT (243453.358 -421760.464) \n", + "996 POINT (172732.681 -389214.320) \n", + "342 POINT (248354.060 -383016.649) \n", + "994 POINT (172437.092 -378906.434) \n", + "\n", + "[37473 rows x 5 columns]" ] }, - "execution_count": 46, + "execution_count": 215, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "row_per_stop.head(3)" + "points_combined" ] }, { "cell_type": "code", - "execution_count": 47, - "id": "dcccae17-5f35-4fc4-a5dc-0e5cf45e2f25", + "execution_count": 161, + "id": "1eaa13fb-88d9-4f5f-ac07-5a5711f974db", "metadata": {}, "outputs": [], "source": [ - "# major_bus_operators = [int(x) for x in list(major_bus.calitp_itp_id.astype(int).unique())]" + "# map_hqta(points_combined)" ] }, { "cell_type": "code", - "execution_count": 48, - "id": "19f9b7dd-1b2b-4c7a-9ba9-3e1e1e9b46be", - "metadata": { - "tags": [] - }, + "execution_count": 224, + "id": "f7d2d824-f02a-450c-a18f-baa4f4b4c8b3", + "metadata": {}, "outputs": [], "source": [ - "# tbl_stops = (tbl.gtfs_schedule.stops() \n", - "# >> filter(_.calitp_itp_id.isin(major_bus_operators))\n", - "# >> select(_.stop_id, _.stop_lat, _.stop_lon, _.calitp_itp_id)\n", - "# >> collect()\n", - "# )\n", - "# tbl_stops = gpd.GeoDataFrame(tbl_stops,\n", - "# geometry = gpd.points_from_xy(tbl_stops.stop_lon, tbl_stops.stop_lat),\n", - "# crs = 'EPSG:4326').to_crs('EPSG:6414') ## https://epsg.io/6414 (meters)" + "names = tbl.views.gtfs_agency_names() >> select(_.calitp_itp_id, _.agency_name) >> collect()\n", + "with_names = points_combined >> inner_join(_, names, on = 'calitp_itp_id')" ] }, { "cell_type": "code", - "execution_count": 49, - "id": "7d959fef-e315-4985-b3fd-72192096a691", + "execution_count": 231, + "id": "f5597551-8553-446b-9f1d-4c9996be932c", "metadata": {}, "outputs": [], "source": [ - "# def join_stops(df):\n", - "# stops_filtered = tbl_stops >> filter(_.calitp_itp_id == int(df.calitp_itp_id.iloc[0]))\n", - "# df = row_per_stop.sjoin(stops_filtered, how='inner', predicate='contains')\n", - "# return df" + "with_names = with_names.drop_duplicates(subset=['calitp_itp_id', 'hqta_type', 'stop_id'])\n", + "with_names = with_names.drop(columns=['calitp_itp_id_2'])" + ] + }, + { + "cell_type": "code", + "execution_count": 233, + "id": "8babf759-70b5-43ca-913b-f3a4f594c30f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idstop_idhqta_typegeometryagency_name
042050major_stop_busPOINT (-197487.747 -22870.228)AC Transit
146160major_stop_busPOINT (-197487.086 -22901.713)AC Transit
246044major_stop_busPOINT (-197515.484 -22863.900)AC Transit
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id stop_id hqta_type geometry \\\n", + "0 4 2050 major_stop_bus POINT (-197487.747 -22870.228) \n", + "1 4 6160 major_stop_bus POINT (-197487.086 -22901.713) \n", + "2 4 6044 major_stop_bus POINT (-197515.484 -22863.900) \n", + "\n", + " agency_name \n", + "0 AC Transit \n", + "1 AC Transit \n", + "2 AC Transit " + ] + }, + "execution_count": 233, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "with_names.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 234, + "id": "136b178e-edc6-4492-a8d9-1a97080f48f2", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/jovyan/data-analyses/high_quality_transit_areas/utilities.py:85: UserWarning: this is an initial implementation of Parquet/Feather file support and associated metadata. This is tracking version 0.1.0 of the metadata specification at https://github.com/geopandas/geo-arrow-spec\n", + "\n", + "This metadata specification does not yet make stability promises. We do not yet recommend using this in a production setting unless you are able to rewrite your Parquet/Feather files.\n", + "\n", + "To further ignore this warning, you can do: \n", + "import warnings; warnings.filterwarnings('ignore', message='.*initial implementation of Parquet.*')\n", + " gdf.to_parquet(f\"{name}.parquet\")\n" + ] + } + ], + "source": [ + "geoparquet_gcs_export(with_names, 'ca_high_quality_transit_points')" ] }, { "cell_type": "code", - "execution_count": 50, - "id": "909f1b0f-0d99-4713-90e5-cf86e7bcab1e", + "execution_count": 235, + "id": "b7cc3286-aa84-4b66-acba-4935481e1650", "metadata": {}, "outputs": [], "source": [ - "# join_to_stop = row_per_stop.groupby('calitp_itp_id').apply(join_stops)" + "with_names.to_file('./ca_high_quality_transit_point.geojson', driver='GeoJSON')" ] }, { - "cell_type": "markdown", - "id": "f1ac0f78-6b99-4079-8c26-ca875367f6a8", + "cell_type": "code", + "execution_count": 236, + "id": "abd4b07a-6804-4f80-9377-ca34208b5e78", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/tmp/ipykernel_44/2615873071.py:1: UserWarning: Column names longer than 10 characters will be truncated when saved to ESRI Shapefile.\n", + " with_names.to_file('./ca_high_quality_transit/ca_high_quality_transit_point.shp')\n" + ] + } + ], + "source": [ + "with_names.to_file('./ca_high_quality_transit/ca_high_quality_transit_point.shp')" + ] + }, + { + "cell_type": "code", + "execution_count": 237, + "id": "62bf6074-7796-4fee-9ea7-9a4d67f438a1", "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['major_stop_bus', 'hq_corridor_bus', 'major_stop_brt',\n", + " 'major_stop_rail', 'major_stop_ferry'], dtype=object)" + ] + }, + "execution_count": 237, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#### Definitions and Output:\n", - "\n", - "* hqta_type: major_transit_stop\n", - "* stop_id: one stop id... (not ideal, but oh well)\n", - "* geometry: .buffer(700)?\n", - "* _can alway pull more info spatially_" + "with_names['hqta_type'].unique()" ] }, { @@ -942,7 +2175,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 28, "id": "e13cb57b-0905-4b8c-9f8f-d6d87c09c533", "metadata": {}, "outputs": [], @@ -954,7 +2187,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 29, "id": "da513fe3-7893-48a1-b33b-de36e5c97443", "metadata": {}, "outputs": [], @@ -968,7 +2201,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 30, "id": "96ea1b81-97d2-4d9f-986b-cb82fcb1d481", "metadata": {}, "outputs": [], @@ -988,7 +2221,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 31, "id": "e25ad411-6ea1-4232-bb47-6df3bb1f4167", "metadata": {}, "outputs": [], @@ -1001,7 +2234,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 32, "id": "fe2aeb20-1714-4543-ba8b-8d655ea1efa4", "metadata": {}, "outputs": [], @@ -1011,19 +2244,41 @@ }, { "cell_type": "code", - "execution_count": 190, + "execution_count": 6, + "id": "92d5b4c7-6723-471f-bafa-dada933393f7", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "all_hqta = gpd.read_parquet(f'{GCS_FILE_PATH}ca_high_quality_transit.parquet')" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "be750b0a-11e8-4905-bc62-6d2b7462a11a", + "metadata": {}, + "outputs": [], + "source": [ + "metro = bus_hqtc >> filter(_.calitp_itp_id == '182')" + ] + }, + { + "cell_type": "code", + "execution_count": 18, "id": "a3adc41e-90f1-4117-8e49-938c4c838a8d", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "4c92e1550b174cb0abb9a992ac7f0e41", + "model_id": "4399525e0c1b47be87a271b99c3093b7", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Map(center=[33.741232185414454, -117.84488376191148], controls=(ZoomControl(options=['position', 'zoom_in_text…" + "Map(center=[34.078792878404975, -118.30956119336547], controls=(ZoomControl(options=['position', 'zoom_in_text…" ] }, "metadata": {}, @@ -1031,31 +2286,15 @@ } ], "source": [ - "map_hqta(all_hqta, 'hqta_type')" + "map_hqta(metro, 'pm_max_trips')" ] }, { "cell_type": "code", - "execution_count": 191, + "execution_count": null, "id": "f614dc84-c6c1-482e-a6eb-d621ccb3af67", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/tmp/ipykernel_46/4200137629.py:1: UserWarning: this is an initial implementation of Parquet/Feather file support and associated metadata. This is tracking version 0.1.0 of the metadata specification at https://github.com/geopandas/geo-arrow-spec\n", - "\n", - "This metadata specification does not yet make stability promises. We do not yet recommend using this in a production setting unless you are able to rewrite your Parquet/Feather files.\n", - "\n", - "To further ignore this warning, you can do: \n", - "import warnings; warnings.filterwarnings('ignore', message='.*initial implementation of Parquet.*')\n", - " all_hqta.to_parquet('./data/combined/ca_high_quality_transit.parquet')\n", - "/tmp/ipykernel_46/4200137629.py:3: UserWarning: Column names longer than 10 characters will be truncated when saved to ESRI Shapefile.\n", - " all_hqta.to_file('./data/combined/ca_high_quality_transit/ca_high_quality_transit.shp')\n" - ] - } - ], + "outputs": [], "source": [ "geoparquet_gcs_export(all_hqta, 'ca_high_quality_transit')\n", "# all_hqta.to_file('./ca_high_quality_transit.geojson', driver='GeoJSON')\n", diff --git a/high_quality_transit_areas/point_exports_opr.ipynb b/high_quality_transit_areas/point_exports_opr.ipynb new file mode 100644 index 000000000..6a08e38d9 --- /dev/null +++ b/high_quality_transit_areas/point_exports_opr.ipynb @@ -0,0 +1,606 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "4a93602d-4289-4d8f-b037-28f244972772", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/opt/conda/lib/python3.9/site-packages/geopandas/_compat.py:111: UserWarning: The Shapely GEOS version (3.9.1-CAPI-1.14.2) is incompatible with the GEOS version PyGEOS was compiled with (3.10.1-CAPI-1.16.0). Conversions between both will be slow.\n", + " warnings.warn(\n" + ] + } + ], + "source": [ + "import calitp\n", + "from calitp.tables import tbl\n", + "from siuba import *\n", + "\n", + "import pandas as pd\n", + "import numpy as np\n", + "import geopandas as gpd\n", + "import fiona\n", + "import shapely\n", + "\n", + "from ipyleaflet import Map, GeoJSON, projections, basemaps, GeoData, LayersControl, WidgetControl, GeoJSON\n", + "from ipywidgets import Text, HTML\n", + "\n", + "from utilities import *" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "e497dcce-0705-4b97-9968-47119cdf386e", + "metadata": {}, + "outputs": [], + "source": [ + "major_bus = gpd.read_parquet(f'{GCS_FILE_PATH}major_bus_stops.parquet')\n", + "major_bus['mode'] = 'bus'" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "12d40de1-7beb-4126-b9ee-14ba288d347f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idstop_idgeometryhqta_typemode
01423977POINT (199058.382 -471125.032)major_transit_stopbus
11423977POINT (198531.592 -471368.189)major_transit_stopbus
21423977POINT (193068.693 -465847.391)major_transit_stopbus
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id stop_id geometry hqta_type \\\n", + "0 142 3977 POINT (199058.382 -471125.032) major_transit_stop \n", + "1 142 3977 POINT (198531.592 -471368.189) major_transit_stop \n", + "2 142 3977 POINT (193068.693 -465847.391) major_transit_stop \n", + "\n", + " mode \n", + "0 bus \n", + "1 bus \n", + "2 bus " + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "major_bus.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d3bda835-a20f-4ad7-9279-0b9f10f36a93", + "metadata": {}, + "outputs": [], + "source": [ + "## rail/ferry/brt explicitly by mode" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "774a2131-9fdc-4386-a003-6310d9ef8c9b", + "metadata": {}, + "outputs": [], + "source": [ + "rail_ferry_brt_stops = gpd.read_parquet(f'{GCS_FILE_PATH}rail_brt_ferry.parquet')" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "29a747be-1fe6-4d83-b65d-da06a1378cf0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['stop_id', 'calitp_itp_id', 'stop_lat', 'stop_lon', 'itp_id_stop_id',\n", + " 'itp_id_trip_id', 'route_id', 'itp_id_route_id', 'trip_id', 'geometry',\n", + " 'calitp_url_number', 'route_type', 'agency_id', 'route_short_name',\n", + " 'route_long_name', 'route_desc', 'route_url', 'route_color',\n", + " 'route_text_color', 'route_sort_order', 'continuous_pickup',\n", + " 'continuous_drop_off', 'calitp_extracted_at'],\n", + " dtype='object')" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rail_ferry_brt_stops.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "id": "956999cb-3445-48d1-9aa3-5c0e3ae32dbc", + "metadata": {}, + "outputs": [], + "source": [ + "rail_ferry_brt_stops['route_type'] = rail_ferry_brt_stops['route_type'].fillna('99')" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "f43e3337-4026-406d-85cc-fcd11d8e1661", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
calitp_itp_idroute_typen
02414
14367
2109910
31399523
41545
54145
6569918
712744
8182355
91829995
10200419
1120099546
122269931
13232329
142469960
1527399104
1627843
1727899121
182799950
19280424
202819910
2128299265
2229499120
233159912
243239962
2533843
\n", + "
" + ], + "text/plain": [ + " calitp_itp_id route_type n\n", + "0 2 4 14\n", + "1 4 3 67\n", + "2 10 99 10\n", + "3 13 99 523\n", + "4 15 4 5\n", + "5 41 4 5\n", + "6 56 99 18\n", + "7 127 4 4\n", + "8 182 3 55\n", + "9 182 99 95\n", + "10 200 4 19\n", + "11 200 99 546\n", + "12 226 99 31\n", + "13 232 3 29\n", + "14 246 99 60\n", + "15 273 99 104\n", + "16 278 4 3\n", + "17 278 99 121\n", + "18 279 99 50\n", + "19 280 4 24\n", + "20 281 99 10\n", + "21 282 99 265\n", + "22 294 99 120\n", + "23 315 99 12\n", + "24 323 99 62\n", + "25 338 4 3" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rail_ferry_brt_stops >> count(_.calitp_itp_id, _.route_type)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "71a2646b-0a53-48e4-ac35-586b2dda3dd3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
stop_idcalitp_itp_idroute_type
0CRN13None
1MKA13None
2OKJ13None
3PLO13None
4QCY13None
............
742483569414
77GF:430002004
78GF:430032004
79GF:430042004
80GF:430072004
\n", + "

2255 rows × 3 columns

\n", + "
" + ], + "text/plain": [ + " stop_id calitp_itp_id route_type\n", + "0 CRN 13 None\n", + "1 MKA 13 None\n", + "2 OKJ 13 None\n", + "3 PLO 13 None\n", + "4 QCY 13 None\n", + ".. ... ... ...\n", + "74 2483569 41 4\n", + "77 GF:43000 200 4\n", + "78 GF:43003 200 4\n", + "79 GF:43004 200 4\n", + "80 GF:43007 200 4\n", + "\n", + "[2255 rows x 3 columns]" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rail_ferry_brt_stops[['stop_id', 'calitp_itp_id', 'route_type']]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b2511687-caf3-4984-91a4-6c0cdeceedd0", + "metadata": {}, + "outputs": [], + "source": [ + "## other stops within hq bus corridor (mode=bus)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "34662e06-2545-48bd-a75d-4f63e2639cb7", + "metadata": {}, + "outputs": [], + "source": [ + "bus_hqtc = gpd.read_parquet(f'{GCS_FILE_PATH}shape_hqta_dissolve.parquet')\n", + "bus_hqtc = bus_hqtc[bus_hqtc['hq_transit_corr']]\n", + "bus_hqtc['hqta_type'] = 'hq_transit_corr'" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "1b71b26f-71ef-449a-a520-7b2a1c8929e3", + "metadata": {}, + "outputs": [], + "source": [ + "all_stops = tbl.gtfs_schedule.stops() >> collect()\n", + "all_stops = gpd.GeoDataFrame(all_stops,\n", + " geometry = gpd.points_from_xy(all_stops.stop_lon, all_stops.stop_lat),\n", + " crs = 'EPSG:4326')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/high_quality_transit_areas/rail_ferry_brt.ipynb b/high_quality_transit_areas/rail_ferry_brt.ipynb index 2ce4cf7e8..706376a07 100644 --- a/high_quality_transit_areas/rail_ferry_brt.ipynb +++ b/high_quality_transit_areas/rail_ferry_brt.ipynb @@ -2,10 +2,31 @@ "cells": [ { "cell_type": "code", - "execution_count": 26, + "execution_count": 1, + "id": "ec2f837d-4bc1-4656-88e3-558e3db2f92c", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# !pip install -r requirements.txt" + ] + }, + { + "cell_type": "code", + "execution_count": 2, "id": "aec8f31d-33de-46fa-be90-79a25e559128", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/opt/conda/lib/python3.9/site-packages/geopandas/_compat.py:111: UserWarning: The Shapely GEOS version (3.9.1-CAPI-1.14.2) is incompatible with the GEOS version PyGEOS was compiled with (3.10.1-CAPI-1.16.0). Conversions between both will be slow.\n", + " warnings.warn(\n" + ] + } + ], "source": [ "import calitp\n", "from calitp.tables import tbl\n", @@ -49,75 +70,137 @@ "id": "6ddca2c1-c222-4a1c-9eeb-5fcbfd4c903f", "metadata": {}, "source": [ - "### Rail Service" + "### Rail Service\n", + "\n", + "* temporary workaround with dim tables, should use tbl.gtfs schedule but LA Metro rail not in" ] }, { "cell_type": "code", "execution_count": 3, - "id": "ccac42d0-6424-4b79-ac9a-b77f7d5536e9", + "id": "f0253d1e-ce54-4c5d-95cb-1e0578a3cb9c", "metadata": {}, "outputs": [], "source": [ - "rail_routes = (tbl.gtfs_schedule.routes()\n", - " >> filter(_.route_type.isin(['0', '1', '2']))\n", - " >> select(_.calitp_itp_id, _.route_id)\n", - " >> collect())" + "rail_routes = (tbl.views.gtfs_schedule_dim_routes()\n", + " >> filter(_.calitp_extracted_at < '2021-11-01')\n", + " >> filter(_.calitp_deleted_at > '2021-11-01')\n", + " >> filter(_.calitp_itp_id != 200) # avoid MTC feed in favor of individual operator feeds\n", + " >> filter((_.route_type == '0') |\n", + " (_.route_type == '1') |\n", + " (_.route_type == '2'))\n", + " # >> filter(_.calitp_itp_id == 182)\n", + " >> select(_.calitp_itp_id, _.calitp_url_number, _.route_id, _.route_type)\n", + " )" ] }, { "cell_type": "code", "execution_count": 4, - "id": "dbcf2c67-44e3-446a-94f3-9a1bb9b04fc6", + "id": "c779f0d3-5253-4a4c-82c2-8741e45cd615", "metadata": {}, "outputs": [], "source": [ - "def routes_to_stops(df_routes):\n", - " df_routes['itp_id_route_id'] = df_routes.calitp_itp_id.astype(str) + df_routes.route_id\n", - " \n", - " df_trips = (tbl.gtfs_schedule.trips()\n", - " >> filter(_.calitp_itp_id.isin(df_routes.calitp_itp_id))\n", - " >> collect()\n", - " >> select(_.calitp_itp_id, _.route_id, _.trip_id)\n", - " >> filter(_.route_id.isin(df_routes.route_id)))\n", - " \n", - " df_trips['itp_id_route_id'] = df_trips.calitp_itp_id.astype(str) + df_trips.route_id\n", - " df_trips.drop(columns=['calitp_itp_id', 'route_id'], inplace=True)\n", - " \n", - " df_trips = df_routes >> inner_join(_, df_trips, on='itp_id_route_id')\n", - " df_trips['itp_id_trip_id'] = df_trips.calitp_itp_id.astype(str) + df_trips.trip_id\n", - " df_operators = [int(str(x)) for x in list(df_trips.calitp_itp_id.unique())]\n", + "def routes_to_stops(routes_tbl):\n", " \n", - " df_stop_times = (tbl.gtfs_schedule.stop_times()\n", - " >> filter(_.calitp_itp_id.isin(df_operators))\n", - " >> select(_.calitp_itp_id, _.stop_id, _.trip_id)\n", + " tbl_trips = (tbl.views.gtfs_schedule_dim_trips()\n", + " >> filter(_.calitp_extracted_at < '2021-11-01')\n", + " >> filter(_.calitp_deleted_at > '2021-11-01')\n", + " >> select(_.calitp_itp_id, _.calitp_url_number, _.route_id, _.trip_id)\n", + " # >> filter(_.calitp_itp_id == 182) ## LA Metro\n", + " # >> filter(_.route_id == '801') ## Metro A Line (Blue) LRT\n", + " >> inner_join(_, routes_tbl, on=['calitp_itp_id', 'calitp_url_number', 'route_id'])\n", + " >> select(_.calitp_itp_id, _.calitp_url_number, _.route_id, _.route_type, _.trip_id)\n", + " # >> collect()\n", + " )\n", + "\n", + " tbl_st_times = (tbl.views.gtfs_schedule_dim_stop_times()\n", + " >> filter(_.calitp_extracted_at < '2021-11-01')\n", + " >> filter(_.calitp_deleted_at > '2021-11-01')\n", + " # >> filter(_.calitp_itp_id.isin(df_operators))\n", + " >> select(_.calitp_itp_id, _.calitp_url_number, _.stop_id, _.trip_id)\n", + " >> inner_join(_, tbl_trips, on=['calitp_itp_id', 'calitp_url_number', 'trip_id'])\n", + " >> distinct(_.calitp_itp_id, _.calitp_url_number, _.stop_id, _.route_type)\n", + " )\n", + "\n", + " stops = (tbl.views.gtfs_schedule_dim_stops()\n", + " >> filter(_.calitp_extracted_at < '2021-11-01')\n", + " >> filter(_.calitp_deleted_at > '2021-11-01')\n", + " >> select(_.calitp_itp_id, _.calitp_url_number,\n", + " _.stop_id, _.stop_lat, _.stop_lon)\n", + " >> inner_join(_, tbl_st_times,\n", + " on = ['calitp_itp_id', 'calitp_url_number', 'stop_id'])\n", " >> collect()\n", - " )\n", - " df_stop_times['itp_id_trip_id'] = df_stop_times.calitp_itp_id.astype(str) + df_stop_times.trip_id\n", - " df_stop_times.drop(columns=['calitp_itp_id', 'trip_id'], inplace=True)\n", - " df_stop_times = df_stop_times >> inner_join(_, df_trips, on='itp_id_trip_id')\n", - " df_stop_times = df_stop_times.drop_duplicates(subset=['stop_id', 'calitp_itp_id'])\n", - " df_stop_times['itp_id_stop_id'] = df_stop_times.calitp_itp_id.astype(str) + df_stop_times.stop_id\n", - " \n", - " df_stops = (tbl.gtfs_schedule.stops()\n", - " >> select(_.stop_id, _.calitp_itp_id, _.stop_lat, _.stop_lon)\n", - " >> filter(_.calitp_itp_id.isin(df_stop_times.calitp_itp_id))\n", - " >> collect()\n", - " )\n", - " \n", - " df_stops['itp_id_stop_id'] = df_stops.calitp_itp_id.astype(str) + df_stops.stop_id\n", - " df_stop_times.drop(columns=['calitp_itp_id', 'stop_id'], inplace=True)\n", - " df_stops = df_stops >> inner_join(_, df_stop_times, on='itp_id_stop_id')\n", - " df_stops = gpd.GeoDataFrame(df_stops,\n", - " geometry = gpd.points_from_xy(df_stops.stop_lon, df_stops.stop_lat),\n", - " crs = 'EPSG:4326')\n", - " return df_stops.to_crs('EPSG:6414') ## https://epsg.io/6414 (meters)" + " )\n", + " stops = gpd.GeoDataFrame(stops,\n", + " geometry = gpd.points_from_xy(stops.stop_lon, stops.stop_lat),\n", + " crs = 'EPSG:4326').to_crs('EPSG:6414') ## https://epsg.io/6414 (meters)\n", + " return stops" ] }, { "cell_type": "code", "execution_count": 5, - "id": "32b0a3a0-cb47-4b38-a5ef-ec4da9b94d3d", + "id": "ccac42d0-6424-4b79-ac9a-b77f7d5536e9", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# rail_routes = (tbl.gtfs_schedule.routes()\n", + "# >> filter((_.route_type == '0') |\n", + "# (_.route_type == '1') |\n", + "# (_.route_type == '2'))\n", + "# >> filter(_.calitp_itp_id == 182)\n", + "# >> select(_.calitp_itp_id, _.calitp_url_number, _.route_id, _.route_type)\n", + "# )" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "687afbd5-c4ca-4076-87a2-2d76e2b556b5", + "metadata": {}, + "outputs": [], + "source": [ + "# tbl_trips = (tbl.gtfs_schedule.trips() \n", + "# >> inner_join(_, rail_routes, on=['calitp_itp_id', 'calitp_url_number', 'route_id'])\n", + "# >> select(_.calitp_itp_id, _.calitp_url_number, _.route_id, _.route_type, _.trip_id)\n", + "# )" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "56f23a2c-6231-472f-9318-efc9d39c90d3", + "metadata": {}, + "outputs": [], + "source": [ + "# tbl_st_times = (tbl.gtfs_schedule.stop_times()\n", + "# >> select(_.calitp_itp_id, _.calitp_url_number, _.stop_id, _.trip_id)\n", + "# >> inner_join(_, tbl_trips, on=['calitp_itp_id', 'calitp_url_number', 'trip_id'])\n", + "# >> distinct(_.calitp_itp_id, _.calitp_url_number, _.stop_id, _.route_type)\n", + "# )" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "01c42d7c-779e-48f2-baf3-b987f4557c6b", + "metadata": {}, + "outputs": [], + "source": [ + "# rail_stops = (tbl.gtfs_schedule.stops()\n", + "# >> select(_.calitp_itp_id, _.calitp_url_number, _.stop_id, _.stop_lat, _.stop_lon)\n", + "# >> inner_join(_, tbl_st_times, on = ['calitp_itp_id', 'calitp_url_number', 'stop_id'])\n", + "# >> collect()\n", + "# )" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "665e8e4b-6bac-44bb-9e37-4e9151186dd3", "metadata": {}, "outputs": [], "source": [ @@ -126,12 +209,12 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 10, "id": "5f0affb3-fa64-40e6-9751-c6b6e0145a30", "metadata": {}, "outputs": [], "source": [ - "# map_hqta(rail_stops)" + "# map_hqta(rail_stops, 'route_type')" ] }, { @@ -148,20 +231,21 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 11, "id": "f5bd001a-1553-46d7-9bed-cb40d457bd54", "metadata": {}, "outputs": [], "source": [ "metro_brt = (tbl.gtfs_schedule.routes()\n", " >> filter(_.calitp_itp_id == 182)\n", - " >> filter(_.route_id.isin(['901-13149', '910-13149']))\n", - " >> collect())" + " >> filter((_.route_id == '901-13149') |\n", + " (_.route_id =='910-13149'))\n", + " )" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 12, "id": "e537715e-576f-400d-b070-f2a2e92107dc", "metadata": {}, "outputs": [], @@ -171,7 +255,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 13, "id": "8a6b60ce-8343-44be-bc13-627da47bad3e", "metadata": {}, "outputs": [], @@ -188,7 +272,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 14, "id": "3bfe1ffb-4b8a-4757-8c7c-a4545d927690", "metadata": {}, "outputs": [], @@ -198,7 +282,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 15, "id": "fd8c3d65-c847-44a3-afd0-d5239e8c8ef3", "metadata": {}, "outputs": [], @@ -208,7 +292,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 16, "id": "1f3f3a84-ff2a-430d-bf1a-9b9ad7df9f79", "metadata": {}, "outputs": [], @@ -216,12 +300,12 @@ "act_brt = (tbl.gtfs_schedule.routes()\n", " >> filter(_.calitp_itp_id == 4)\n", " >> filter(_.route_id == '1T')\n", - " >> collect())" + " )" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 17, "id": "75ab0103-b13a-4bcd-992c-f550ac0d7c63", "metadata": {}, "outputs": [], @@ -231,7 +315,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 18, "id": "501c99f8-5c67-4619-9d2d-26d122275d33", "metadata": {}, "outputs": [], @@ -241,7 +325,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 19, "id": "dea32983-6c05-4dbb-b5a8-3964c2665ad9", "metadata": {}, "outputs": [], @@ -249,12 +333,12 @@ "omni_brt = (tbl.gtfs_schedule.routes()\n", " >> filter(_.calitp_itp_id == 232)\n", " >> filter(_.route_id == '9648')\n", - " >> collect())" + " )" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 20, "id": "d14872f0-f932-4d44-9fa1-07e6c6598d6b", "metadata": {}, "outputs": [], @@ -264,7 +348,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 21, "id": "da92e541-49f1-4f2e-ba6d-337456db5346", "metadata": {}, "outputs": [], @@ -282,7 +366,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 22, "id": "a1291f99-2560-4d3b-8155-02a6fbc08bbc", "metadata": {}, "outputs": [], @@ -290,12 +374,12 @@ "ferry = (tbl.gtfs_schedule.routes()\n", " >> filter(_.route_type == '4')\n", " # >> filter(_.route_id == '9648')\n", - " >> collect())" + " )" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 23, "id": "c4cf42ea-7740-45ed-a2dc-0e769ae90715", "metadata": {}, "outputs": [], @@ -307,7 +391,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 24, "id": "5de12b81-e461-4f5e-955d-2df1abfdd6e3", "metadata": {}, "outputs": [], @@ -325,7 +409,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 25, "id": "0d1364e9-8b07-4b3d-a7fb-b73b868f5f98", "metadata": {}, "outputs": [], @@ -339,7 +423,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 26, "id": "eb2ff617-0944-4720-90ac-0c03e296789e", "metadata": {}, "outputs": [ @@ -364,149 +448,65 @@ " \n", " \n", " \n", - " stop_id\n", " calitp_itp_id\n", + " calitp_url_number\n", + " stop_id\n", " stop_lat\n", " stop_lon\n", - " itp_id_stop_id\n", - " itp_id_trip_id\n", - " route_id\n", - " itp_id_route_id\n", - " trip_id\n", + " route_type\n", " geometry\n", - " ...\n", - " route_short_name\n", - " route_long_name\n", - " route_desc\n", - " route_url\n", - " route_color\n", - " route_text_color\n", - " route_sort_order\n", - " continuous_pickup\n", - " continuous_drop_off\n", - " calitp_extracted_at\n", " \n", " \n", " \n", " \n", " 0\n", - " CRN\n", - " 13\n", - " 41.056920\n", - " -94.361617\n", - " 13CRN\n", - " 1352818299\n", - " 96\n", - " 1396\n", - " 52818299\n", - " POINT (2130400.260 627641.309)\n", - " ...\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", + " 10\n", + " 0\n", + " 3400002\n", + " 37.797908\n", + " -121.263664\n", + " 2\n", + " POINT (-111116.950 -23544.700)\n", " \n", " \n", " 1\n", - " MKA\n", - " 13\n", - " 42.940583\n", - " -87.924359\n", - " 13MKA\n", - " 133412815756\n", - " 54\n", - " 1354\n", - " 3412815756\n", - " POINT (2577583.013 986856.496)\n", - " ...\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", + " 10\n", + " 0\n", + " 3400001\n", + " 37.957058\n", + " -121.278948\n", + " 2\n", + " POINT (-112222.169 -5836.078)\n", " \n", " \n", " 2\n", - " OKJ\n", - " 13\n", - " 37.793866\n", - " -122.271667\n", - " 13OKJ\n", - " 135452816206\n", - " 84\n", - " 1384\n", - " 5452816206\n", - " POINT (-199750.592 -22341.380)\n", - " ...\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", + " 10\n", + " 0\n", + " 3400003\n", + " 37.696468\n", + " -121.433869\n", + " 2\n", + " POINT (-126252.943 -34607.238)\n", " \n", " \n", " 3\n", - " PLO\n", - " 13\n", - " 41.662384\n", - " -88.538272\n", - " 13PLO\n", - " 133832815187\n", - " 93\n", - " 1393\n", - " 3832815187\n", - " POINT (2576234.283 836414.716)\n", - " ...\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", + " 10\n", + " 0\n", + " 3400004.3\n", + " 37.657549\n", + " -121.882962\n", + " 2\n", + " POINT (-165877.168 -38241.179)\n", " \n", " \n", " 4\n", - " QCY\n", - " 13\n", - " 39.957063\n", - " -91.368525\n", - " 13QCY\n", - " 133832815187\n", - " 93\n", - " 1393\n", - " 3832815187\n", - " POINT (2408238.879 582112.897)\n", - " ...\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", - " NaN\n", + " 10\n", + " 0\n", + " 3400004.1\n", + " 37.697081\n", + " -121.717648\n", + " 2\n", + " POINT (-151236.096 -34123.815)\n", " \n", " \n", " ...\n", @@ -517,242 +517,93 @@ " ...\n", " ...\n", " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", " \n", " \n", - " 74\n", - " 2483569\n", + " 28\n", " 41\n", - " 37.856636\n", - " -122.478275\n", - " 412483569\n", - " 41t_373938_b_28421_tn_0\n", - " 11643\n", - " 4111643\n", - " t_373938_b_28421_tn_0\n", - " POINT (-217731.552 -14910.728)\n", - " ...\n", - " None\n", - " Pier 41 - Sausalito - Tiburon - Angel Island\n", - " None\n", - " None\n", - " f5cb04\n", - " 000000\n", - " 3\n", - " 1\n", - " 1\n", - " 2021-05-03\n", + " 0\n", + " 2483549\n", + " 37.872939\n", + " -122.455446\n", + " 4\n", + " POINT (-215679.403 -13151.168)\n", " \n", " \n", - " 77\n", - " GF:43000\n", - " 200\n", - " 37.795869\n", - " -122.392450\n", - " 200GF:43000\n", - " 200GF:7296302\n", - " GF:SF\n", - " 200GF:SF\n", - " GF:7296302\n", - " POINT (-210363.380 -21857.544)\n", - " ...\n", - " SF\n", - " Sausalito - San Francisco Ferry\n", - " None\n", - " http://goldengateferry.org/schedules/Sausalito...\n", - " 0000FF\n", - " FFFFFF\n", + " 29\n", + " 41\n", " 0\n", - " None\n", - " None\n", - " 2021-11-07\n", + " 2483569\n", + " 37.856636\n", + " -122.478275\n", + " 4\n", + " POINT (-217731.552 -14910.728)\n", " \n", " \n", - " 78\n", - " GF:43003\n", - " 200\n", - " 37.856401\n", - " -122.478251\n", - " 200GF:43003\n", - " 200GF:7296302\n", - " GF:SF\n", - " 200GF:SF\n", - " GF:7296302\n", - " POINT (-217730.126 -14936.899)\n", - " ...\n", - " SF\n", - " Sausalito - San Francisco Ferry\n", - " None\n", - " http://goldengateferry.org/schedules/Sausalito...\n", - " 0000FF\n", - " FFFFFF\n", + " 31\n", + " 338\n", " 0\n", - " None\n", - " None\n", - " 2021-11-07\n", + " 818729\n", + " 37.770840\n", + " -122.385791\n", + " 4\n", + " POINT (-209847.993 -24653.833)\n", " \n", " \n", - " 79\n", - " GF:43004\n", - " 200\n", - " 37.945316\n", - " -122.508735\n", - " 200GF:43004\n", - " 200GF:7296280\n", - " GF:LF\n", - " 200GF:LF\n", - " GF:7296280\n", - " POINT (-220146.197 -4985.515)\n", - " ...\n", - " LF\n", - " Larkspur - San Francisco Ferry\n", - " None\n", - " http://goldengateferry.org/schedules/Larkspur.php\n", - " 0000FF\n", - " FFFFFF\n", + " 32\n", + " 338\n", " 0\n", - " None\n", - " None\n", - " 2021-11-07\n", + " 818733\n", + " 37.864540\n", + " -122.313932\n", + " 4\n", + " POINT (-203274.531 -14397.269)\n", " \n", " \n", - " 80\n", - " GF:43007\n", - " 200\n", - " 37.872770\n", - " -122.455928\n", - " 200GF:43007\n", - " 200GF:7309934\n", - " GF:TF\n", - " 200GF:TF\n", - " GF:7309934\n", - " POINT (-215722.217 -13168.852)\n", - " ...\n", - " TF\n", - " Tiburon - San Francisco Ferry\n", - " None\n", - " None\n", - " 0000FF\n", - " FFFFFF\n", + " 33\n", + " 338\n", " 0\n", - " None\n", - " None\n", - " 2021-11-07\n", + " 818727\n", + " 37.797482\n", + " -122.395025\n", + " 4\n", + " POINT (-210585.228 -21672.628)\n", " \n", " \n", "\n", - "

2255 rows × 23 columns

\n", + "

1324 rows × 7 columns

\n", "" ], "text/plain": [ - " stop_id calitp_itp_id stop_lat stop_lon itp_id_stop_id \\\n", - "0 CRN 13 41.056920 -94.361617 13CRN \n", - "1 MKA 13 42.940583 -87.924359 13MKA \n", - "2 OKJ 13 37.793866 -122.271667 13OKJ \n", - "3 PLO 13 41.662384 -88.538272 13PLO \n", - "4 QCY 13 39.957063 -91.368525 13QCY \n", - ".. ... ... ... ... ... \n", - "74 2483569 41 37.856636 -122.478275 412483569 \n", - "77 GF:43000 200 37.795869 -122.392450 200GF:43000 \n", - "78 GF:43003 200 37.856401 -122.478251 200GF:43003 \n", - "79 GF:43004 200 37.945316 -122.508735 200GF:43004 \n", - "80 GF:43007 200 37.872770 -122.455928 200GF:43007 \n", - "\n", - " itp_id_trip_id route_id itp_id_route_id trip_id \\\n", - "0 1352818299 96 1396 52818299 \n", - "1 133412815756 54 1354 3412815756 \n", - "2 135452816206 84 1384 5452816206 \n", - "3 133832815187 93 1393 3832815187 \n", - "4 133832815187 93 1393 3832815187 \n", - ".. ... ... ... ... \n", - "74 41t_373938_b_28421_tn_0 11643 4111643 t_373938_b_28421_tn_0 \n", - "77 200GF:7296302 GF:SF 200GF:SF GF:7296302 \n", - "78 200GF:7296302 GF:SF 200GF:SF GF:7296302 \n", - "79 200GF:7296280 GF:LF 200GF:LF GF:7296280 \n", - "80 200GF:7309934 GF:TF 200GF:TF GF:7309934 \n", - "\n", - " geometry ... route_short_name \\\n", - "0 POINT (2130400.260 627641.309) ... NaN \n", - "1 POINT (2577583.013 986856.496) ... NaN \n", - "2 POINT (-199750.592 -22341.380) ... NaN \n", - "3 POINT (2576234.283 836414.716) ... NaN \n", - "4 POINT (2408238.879 582112.897) ... NaN \n", - ".. ... ... ... \n", - "74 POINT (-217731.552 -14910.728) ... None \n", - "77 POINT (-210363.380 -21857.544) ... SF \n", - "78 POINT (-217730.126 -14936.899) ... SF \n", - "79 POINT (-220146.197 -4985.515) ... LF \n", - "80 POINT (-215722.217 -13168.852) ... TF \n", - "\n", - " route_long_name route_desc \\\n", - "0 NaN NaN \n", - "1 NaN NaN \n", - "2 NaN NaN \n", - "3 NaN NaN \n", - "4 NaN NaN \n", - ".. ... ... \n", - "74 Pier 41 - Sausalito - Tiburon - Angel Island None \n", - "77 Sausalito - San Francisco Ferry None \n", - "78 Sausalito - San Francisco Ferry None \n", - "79 Larkspur - San Francisco Ferry None \n", - "80 Tiburon - San Francisco Ferry None \n", - "\n", - " route_url route_color \\\n", - "0 NaN NaN \n", - "1 NaN NaN \n", - "2 NaN NaN \n", - "3 NaN NaN \n", - "4 NaN NaN \n", - ".. ... ... \n", - "74 None f5cb04 \n", - "77 http://goldengateferry.org/schedules/Sausalito... 0000FF \n", - "78 http://goldengateferry.org/schedules/Sausalito... 0000FF \n", - "79 http://goldengateferry.org/schedules/Larkspur.php 0000FF \n", - "80 None 0000FF \n", - "\n", - " route_text_color route_sort_order continuous_pickup continuous_drop_off \\\n", - "0 NaN NaN NaN NaN \n", - "1 NaN NaN NaN NaN \n", - "2 NaN NaN NaN NaN \n", - "3 NaN NaN NaN NaN \n", - "4 NaN NaN NaN NaN \n", - ".. ... ... ... ... \n", - "74 000000 3 1 1 \n", - "77 FFFFFF 0 None None \n", - "78 FFFFFF 0 None None \n", - "79 FFFFFF 0 None None \n", - "80 FFFFFF 0 None None \n", + " calitp_itp_id calitp_url_number stop_id stop_lat stop_lon \\\n", + "0 10 0 3400002 37.797908 -121.263664 \n", + "1 10 0 3400001 37.957058 -121.278948 \n", + "2 10 0 3400003 37.696468 -121.433869 \n", + "3 10 0 3400004.3 37.657549 -121.882962 \n", + "4 10 0 3400004.1 37.697081 -121.717648 \n", + ".. ... ... ... ... ... \n", + "28 41 0 2483549 37.872939 -122.455446 \n", + "29 41 0 2483569 37.856636 -122.478275 \n", + "31 338 0 818729 37.770840 -122.385791 \n", + "32 338 0 818733 37.864540 -122.313932 \n", + "33 338 0 818727 37.797482 -122.395025 \n", "\n", - " calitp_extracted_at \n", - "0 NaN \n", - "1 NaN \n", - "2 NaN \n", - "3 NaN \n", - "4 NaN \n", - ".. ... \n", - "74 2021-05-03 \n", - "77 2021-11-07 \n", - "78 2021-11-07 \n", - "79 2021-11-07 \n", - "80 2021-11-07 \n", + " route_type geometry \n", + "0 2 POINT (-111116.950 -23544.700) \n", + "1 2 POINT (-112222.169 -5836.078) \n", + "2 2 POINT (-126252.943 -34607.238) \n", + "3 2 POINT (-165877.168 -38241.179) \n", + "4 2 POINT (-151236.096 -34123.815) \n", + ".. ... ... \n", + "28 4 POINT (-215679.403 -13151.168) \n", + "29 4 POINT (-217731.552 -14910.728) \n", + "31 4 POINT (-209847.993 -24653.833) \n", + "32 4 POINT (-203274.531 -14397.269) \n", + "33 4 POINT (-210585.228 -21672.628) \n", "\n", - "[2255 rows x 23 columns]" + "[1324 rows x 7 columns]" ] }, - "execution_count": 22, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -763,7 +614,63 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 27, + "id": "c957af13-3cab-44ef-8c64-830f5d8f1a2f", + "metadata": {}, + "outputs": [], + "source": [ + "## clip to CA since we now have Amtrak national..." + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "b4d279ae-5283-47e6-b503-f01738f7672a", + "metadata": {}, + "outputs": [], + "source": [ + "import intake\n", + "catalog = intake.open_catalog('./catalog.yml')" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "c76728cc-b293-4f57-8002-3efa845a1dad", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "ca_shape = catalog.stanford_shorelines.read().to_crs('EPSG:6414') >> filter(_.STFIPS == '06')" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "0174ddab-347c-47d2-b824-98e360719b94", + "metadata": {}, + "outputs": [], + "source": [ + "## after this cell displays output the notebook refuses to save...\n", + "## File Save Error for rail_ferry_brt.ipynb\n", + "## Invalid response: 413 Request Entity Too Large\n", + "# ca_shape['geometry'].iloc[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "8b7beb5f-2128-4482-9648-abdfcc8e0001", + "metadata": {}, + "outputs": [], + "source": [ + "rail_brt_ferry = rail_brt_ferry.clip(ca_shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 32, "id": "fa029d00-acac-4242-9048-d8024e70f914", "metadata": {}, "outputs": [], @@ -773,7 +680,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 33, "id": "ba7057fc-a405-461c-ae65-230966fe9bfa", "metadata": {}, "outputs": [