Spaces:
Sleeping

dn commited on
Commit
9dfcd18
·
1 Parent(s): cabbd02
Files changed (2) hide show
  1. notebooks/sb79map.py +14 -34
  2. pyproject.toml +1 -0
notebooks/sb79map.py CHANGED
@@ -16,7 +16,7 @@ __generated_with = "0.23.5"
16
  app = marimo.App()
17
 
18
  with app.setup(hide_code=True):
19
- import csv
20
  import io
21
  import json
22
  import tempfile
@@ -34,6 +34,13 @@ with app.setup(hide_code=True):
34
  import shapely
35
  from shapely import unary_union
36
  from shapely.geometry import Polygon
 
 
 
 
 
 
 
37
 
38
  __generated_with = "0.23.5"
39
  SCAG_PARCELS_URL = "https://rdp.scag.ca.gov/mapping/rest/services/Housing/2020_Annual_Land_Use/MapServer/0/query"
@@ -880,33 +887,14 @@ with app.setup(hide_code=True):
880
 
881
  return result
882
 
883
-
884
- @app.cell(hide_code=True)
885
- def _():
886
- from typing import Optional
887
-
888
- import folium
889
- import marimo as mo
890
- from folium.plugins import MarkerCluster, VectorGridProtobuf
891
-
892
  PARCELS_URL = "https://vectortileservices3.arcgis.com/NaFf4UaPo3IgQXqn/arcgis/rest/services/sb79_transit_parcels/VectorTileServer/tile/{z}/{y}/{x}.pbf"
893
  STOPS_URL = (
894
  "https://services3.arcgis.com/NaFf4UaPo3IgQXqn/ArcGIS/rest/services/sb79_transit_stations/FeatureServer/0/query"
895
  )
896
- return (
897
- MarkerCluster,
898
- Optional,
899
- PARCELS_URL,
900
- STOPS_URL,
901
- VectorGridProtobuf,
902
- folium,
903
- mo,
904
- )
905
 
906
 
907
  @app.cell(hide_code=True)
908
- def _(mo):
909
-
910
  file_input = mo.ui.file(
911
  label="Upload a GTFS zip file",
912
  filetypes=[".zip"],
@@ -922,18 +910,10 @@ def _(mo):
922
  return file_input, url_input
923
 
924
 
925
- @app.cell(hide_code=True)
926
- def _(mo):
927
- mo.stop(True, mo.md("**Upload GTFS to continue.**"))
928
- return
929
-
930
-
931
- @app.cell(hide_code=True)
932
- def _(Optional, file_input, url_input):
933
  # --- React to user input ---
934
- print("Getting GTFS zip file from github")
935
-
936
- def get_gtfs_bytes() -> Optional[bytes]:
937
  """Return GTFS bytes from whichever input the user used."""
938
  if file_input.value:
939
  # Uploaded file -> file_input.value is a list of named tuples (name, contents)
@@ -1096,14 +1076,14 @@ def _(stops_result):
1096
 
1097
 
1098
  @app.cell(hide_code=True)
1099
- def _(STOPS_URL):
1100
  stops = fetch_from_arcgis(url=STOPS_URL)
1101
  stops = stops.set_crs("EPSG:4326")
1102
  return (stops,)
1103
 
1104
 
1105
  @app.cell(hide_code=True)
1106
- def _(MarkerCluster, PARCELS_URL, VectorGridProtobuf, folium, stops):
1107
  m = folium.Map(location=[34.0617140033952, -118.314146442073], tiles="CartoDB Positron", zoom_start=5)
1108
 
1109
  VectorGridProtobuf(PARCELS_URL, "folium_layer_name").add_to(m)
 
16
  app = marimo.App()
17
 
18
  with app.setup(hide_code=True):
19
+ import csv # noqa: I001
20
  import io
21
  import json
22
  import tempfile
 
34
  import shapely
35
  from shapely import unary_union
36
  from shapely.geometry import Polygon
37
+ from typing import Optional
38
+
39
+ import folium
40
+ import marimo as mo
41
+ from folium.plugins import MarkerCluster, VectorGridProtobuf
42
+ import mapclassify # noqa: f401
43
+ import matplotlib # noqa: f401
44
 
45
  __generated_with = "0.23.5"
46
  SCAG_PARCELS_URL = "https://rdp.scag.ca.gov/mapping/rest/services/Housing/2020_Annual_Land_Use/MapServer/0/query"
 
887
 
888
  return result
889
 
 
 
 
 
 
 
 
 
 
890
  PARCELS_URL = "https://vectortileservices3.arcgis.com/NaFf4UaPo3IgQXqn/arcgis/rest/services/sb79_transit_parcels/VectorTileServer/tile/{z}/{y}/{x}.pbf"
891
  STOPS_URL = (
892
  "https://services3.arcgis.com/NaFf4UaPo3IgQXqn/ArcGIS/rest/services/sb79_transit_stations/FeatureServer/0/query"
893
  )
 
 
 
 
 
 
 
 
 
894
 
895
 
896
  @app.cell(hide_code=True)
897
+ def _():
 
898
  file_input = mo.ui.file(
899
  label="Upload a GTFS zip file",
900
  filetypes=[".zip"],
 
910
  return file_input, url_input
911
 
912
 
913
+ @app.cell
914
+ def _(file_input, url_input):
 
 
 
 
 
 
915
  # --- React to user input ---
916
+ def get_gtfs_bytes() -> bytes | None:
 
 
917
  """Return GTFS bytes from whichever input the user used."""
918
  if file_input.value:
919
  # Uploaded file -> file_input.value is a list of named tuples (name, contents)
 
1076
 
1077
 
1078
  @app.cell(hide_code=True)
1079
+ def _():
1080
  stops = fetch_from_arcgis(url=STOPS_URL)
1081
  stops = stops.set_crs("EPSG:4326")
1082
  return (stops,)
1083
 
1084
 
1085
  @app.cell(hide_code=True)
1086
+ def _(stops):
1087
  m = folium.Map(location=[34.0617140033952, -118.314146442073], tiles="CartoDB Positron", zoom_start=5)
1088
 
1089
  VectorGridProtobuf(PARCELS_URL, "folium_layer_name").add_to(m)
pyproject.toml CHANGED
@@ -41,6 +41,7 @@ select = [
41
 
42
  ignore = [
43
  "B018", # Found useless expression (sometimes used for output in notebooks)
 
44
  ]
45
 
46
  [tool.marimo.runtime]
 
41
 
42
  ignore = [
43
  "B018", # Found useless expression (sometimes used for output in notebooks)
44
+ "F401"
45
  ]
46
 
47
  [tool.marimo.runtime]