Spaces:
Sleeping

dn commited on
Commit
4c2ea61
·
1 Parent(s): a762449

marimo.ui. file_browser => file

Browse files
Files changed (1) hide show
  1. notebooks/sb79map.py +29 -27
notebooks/sb79map.py CHANGED
@@ -16,6 +16,7 @@ __generated_with = "0.23.6"
16
  app = marimo.App()
17
 
18
  with app.setup(hide_code=True):
 
19
  from pathlib import Path
20
 
21
  import folium
@@ -39,49 +40,47 @@ with app.setup(hide_code=True):
39
  @app.cell(hide_code=True)
40
  def _():
41
  mo.md("""
42
- # SB-79 Analysis
43
- [Code for this notebook.](https://github.com/dknomura/missing_metro/blob/main/notebooks/sb79map.py)
44
 
45
- ## Instructions
46
- 1. If you do not have a GTFS zip file, download one of the following for a demo
47
  - [OC Streetcar GTFS](https://github.com/dknomura/missing_metro/raw/refs/heads/main/notebooks/public/oc-streetcar_gtfs.zip)
48
  - [LA Metro GTFS](https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip) this will take 5-10 min
49
- 2. GTFS file needs to be for a transit system in the SCAG region (LA, Orange, Riverside, San Bernardino, Ventura).
50
 
51
 
52
- ## Overview of SB-79 analysis
53
- SB-79 is a California bill that promotes transit oriented development by allowing increased residential density
54
- and reduced parking requirements within a half mile of qualifying transit stations.
55
- The two tables below summarize the tier designations and the zoning allowances under SB-79.
56
 
57
- | **Table 1: Tier designations** | | | |
58
- |--------|----------------------|----|--------------------------------------------|
59
- | Tier 1 | Heavy rail (subway) | or | Commuter rail with more than 72 trains/day |
60
- | Tier 2 | Light rail | or | Commuter rail with more than 48 trains/day |
61
 
62
- **Table 2: Permitted Zoning Based on Distance from Station (du/ac = dwelling units / acre)**
63
 
64
- | | Within 200 feet of a station | Within ¼ mile of a station | Within ½ mile of a station |
65
- |--------|------------------------------|---------------------------|---------------------------|
66
- | Tier 1 | 9 stories (160 du/ac) | 7 stories (120 du/ac) | 6 stories (100 du/ac) |
67
- | Tier 2 | 8 stories (140 du/ac) | 6 stories (100 du/ac) | 5 stories (80 du/ac) |
68
 
69
- This notebook takes in a General Transit Feed Specification (GTFS) zip file and uses SCAG zoning parcel data to calculate
70
- the density and dwelling units that are currently permitted and compares it with the potential under SB-79.
71
- """)
72
  return
73
 
74
 
75
  @app.cell(hide_code=True)
76
  def _():
77
- file_input = mo.ui.file_browser(
78
- initial_path=str(Path.home() / "Downloads"),
79
  label="Select a GTFS zip file to initiate the SB-79 analysis",
80
  filetypes=[".zip"],
81
- multiple=False,
82
  )
83
 
84
- mo.hstack([file_input], justify="start")
85
  return (file_input,)
86
 
87
 
@@ -89,7 +88,11 @@ def _():
89
  def _(file_input):
90
  mo.stop(not file_input.value, mo.md("⬆️ Upload a GTFS zip to continue"))
91
 
92
- new_stops = assign_tier_to_stops_from_gtfs(str(file_input.path()))
 
 
 
 
93
  return (new_stops,)
94
 
95
 
@@ -143,7 +146,6 @@ def _(file_input, scag_parcels):
143
  label="Page",
144
  )
145
  page
146
-
147
  return page, page_size
148
 
149
 
 
16
  app = marimo.App()
17
 
18
  with app.setup(hide_code=True):
19
+ import tempfile
20
  from pathlib import Path
21
 
22
  import folium
 
40
  @app.cell(hide_code=True)
41
  def _():
42
  mo.md("""
43
+ # SB-79 Analysis
44
+ [Code for this notebook.](https://github.com/dknomura/missing_metro/blob/main/notebooks/sb79map.py)
45
 
46
+ ## Instructions
47
+ 1. If you do not have a GTFS zip file, download one of the following for a demo
48
  - [OC Streetcar GTFS](https://github.com/dknomura/missing_metro/raw/refs/heads/main/notebooks/public/oc-streetcar_gtfs.zip)
49
  - [LA Metro GTFS](https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip) this will take 5-10 min
50
+ 2. GTFS file needs to be for a transit system in the SCAG region (LA, Orange, Riverside, San Bernardino, Ventura).
51
 
52
 
53
+ ## Overview of SB-79 analysis
54
+ SB-79 is a California bill that promotes transit oriented development by allowing increased residential density
55
+ and reduced parking requirements within a half mile of qualifying transit stations.
56
+ The two tables below summarize the tier designations and the zoning allowances under SB-79.
57
 
58
+ | **Table 1: Tier designations** | | | |
59
+ |--------|----------------------|----|--------------------------------------------|
60
+ | Tier 1 | Heavy rail (subway) | or | Commuter rail with more than 72 trains/day |
61
+ | Tier 2 | Light rail | or | Commuter rail with more than 48 trains/day |
62
 
63
+ **Table 2: Permitted Zoning Based on Distance from Station (du/ac = dwelling units / acre)**
64
 
65
+ | | Within 200 feet of a station | Within ¼ mile of a station | Within ½ mile of a station |
66
+ |--------|------------------------------|---------------------------|---------------------------|
67
+ | Tier 1 | 9 stories (160 du/ac) | 7 stories (120 du/ac) | 6 stories (100 du/ac) |
68
+ | Tier 2 | 8 stories (140 du/ac) | 6 stories (100 du/ac) | 5 stories (80 du/ac) |
69
 
70
+ This notebook takes in a General Transit Feed Specification (GTFS) zip file and uses SCAG zoning parcel data to calculate
71
+ the density and dwelling units that are currently permitted and compares it with the potential under SB-79.
72
+ """)
73
  return
74
 
75
 
76
  @app.cell(hide_code=True)
77
  def _():
78
+ file_input = mo.ui.file(
 
79
  label="Select a GTFS zip file to initiate the SB-79 analysis",
80
  filetypes=[".zip"],
 
81
  )
82
 
83
+ file_input
84
  return (file_input,)
85
 
86
 
 
88
  def _(file_input):
89
  mo.stop(not file_input.value, mo.md("⬆️ Upload a GTFS zip to continue"))
90
 
91
+ with tempfile.NamedTemporaryFile(delete=False) as tmp:
92
+ tmp.write(file_input.value[0].contents)
93
+ tmp.flush()
94
+
95
+ new_stops = assign_tier_to_stops_from_gtfs(tmp.name, tier_overrides={"route-mourbghe-3": 2})
96
  return (new_stops,)
97
 
98
 
 
146
  label="Page",
147
  )
148
  page
 
149
  return page, page_size
150
 
151