Skip to content

Instantly share code, notes, and snippets.

View stevevance's full-sized avatar
🏠
Working from home

Steven Vance stevevance

🏠
Working from home
View GitHub Profile
@stevevance
stevevance / zoning_capacity_by_communityarea.tsv
Created October 10, 2022 20:16
community areas ordered by zoned dwelling unit capacity
units communityarea
396565 Loop
175567 Near North Side
129848 Near West Side
65285 Lake View
47508 Grand Boulevard
45747 South Shore
44116 West Town
42172 Uptown
39826 Lincoln Park
@stevevance
stevevance / chicago_zoning_capacity.sql
Created October 10, 2022 20:02
Query to calculate how many dwelling units are allowed at each parcel in Chicago
with properties as (
SELECT
data.pin14 AS pin14,
ca.community,
joined_2.zone_class AS zone_class,
CASE WHEN lot_area_per_unit IS NOT NULL AND lot_area_per_unit > 0 AND property_class != '2-99'
/* this excludes condos, property class of 2-99, because those parcels are duplicates of the footprint parcel */
THEN floor(area/lot_area_per_unit)
ELSE null
END AS units_allowed
@stevevance
stevevance / cast_dates.sql
Created October 9, 2022 00:13
handle invalid dates in Illinois Secretary of State incorporation data
create or replace function is_date(s varchar) returns boolean as $$
/* function via https://stackoverflow.com/a/25374982 */
begin
perform s::date;
return true;
exception when others then
return false;
end;
$$ language plpgsql;
@stevevance
stevevance / adjacent_parcels.sql
Created January 25, 2022 03:03
How to find adjacent parcels
/* thanks to https://stackoverflow.com/a/12521268/464883 for help writing the query */
/* find 2 parcels that share an edge */
SELECT DISTINCT v1.pin14, v1.property_class
FROM view_cook_scavenger_sale_2022 v1
WHERE EXISTS (
SELECT v2.pin14 FROM view_cook_scavenger_sale_2022 v2
WHERE st_touches(v1.geom, v2.geom)
and v2.area >= 3000
)
@stevevance
stevevance / gist:fd12a4fbd6a2fc7e33ad71601809f44d
Created December 10, 2021 00:23
Reverse geocoders both think that this Chicago address is in Elmwood Park
api_key='ge-feb60a22792061e2'
curl --get https://api.geocode.earth/v1/reverse \
-d api_key=$api_key \
-d point.lat=41.9305 \
-d point.lon=-87.79511
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode \
-d 'f=pjson' \
-d 'location=-87.79511,41.9305' \
@stevevance
stevevance / foia_request_treasurer_list_of_pins.txt
Created October 27, 2021 17:18
FOIA request language for data in the public interest
Pursuant to the Illinois Freedom of Information Act., I hereby request the following records:
A list of the 14-digit PINs that were active in the 2019 property tax year, preferably in a spreadsheet form like XLS, XLSX, or CSV.
I think that fees should be waived. Publishing a list of properties, identified by their PIN, in the 2019 property tax year is in the public interest because it enables the public to have more insight and transparency around the Cook County property taxing processes which were largely opaque until the Chicago Tribune investigation in 2017 that identified multiple issues.
This list is the basic starting point to any analysis because it shows which properties are active in that and can be analyzed for their tax revenue contributions and compared to previous years.
The requested documents will be made available to the general public, and this request is not being made for commercial purposes.
@stevevance
stevevance / developments_2021_07_05.txt
Last active July 5, 2021 18:22
Significant Neighborhood Development as of July 5, 2021
This text accompanies a tweet posted on Monday, July 5, 2021, at 13:21, that says, "We show "significant neighborhood developments" on our homepage to demonstrate the variety of things happening across the city...What are we missing?" Three images depicting maps were attached.
https://twitter.com/ChiBuildings/status/1412114349871751170
This is the alternative text for the locations and projects shown on the three maps.
Red Line riders who use Lawrence, Argyle, Berwyn, and Bryn Mawr can look forward to brand new stations and faster service by 2025.
A new CTA station will open at Green Line at Damen/Lake, but construction hasn't started.
A landmarked house where Emmett Till grew up and where his mother, Mamie Till-Mobley, lived as she did civil rights activism, will become a house museum to be developed by Blacks In Green.
A landmarked house that once belonged to McKinley Morganfield, known professionally as Muddy Waters, a famous Chicago Blues musician, is being developed into a house museum.
Chicago's pla
@stevevance
stevevance / ALBANY_DIVERSEY_PEDESTRIAN.csv
Created April 13, 2021 01:21
Pedestrian crashes on Diversey or Albany since September 2017
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 49 columns, instead of 12 in line 1.
CRASH_RECORD_ID,RD_NO,CRASH_DATE_EST_I,CRASH_DATE,POSTED_SPEED_LIMIT,TRAFFIC_CONTROL_DEVICE,DEVICE_CONDITION,WEATHER_CONDITION,LIGHTING_CONDITION,FIRST_CRASH_TYPE,TRAFFICWAY_TYPE,LANE_CNT,ALIGNMENT,ROADWAY_SURFACE_COND,ROAD_DEFECT,REPORT_TYPE,CRASH_TYPE,INTERSECTION_RELATED_I,NOT_RIGHT_OF_WAY_I,HIT_AND_RUN_I,DAMAGE,DATE_POLICE_NOTIFIED,PRIM_CONTRIBUTORY_CAUSE,SEC_CONTRIBUTORY_CAUSE,STREET_NO,STREET_DIRECTION,STREET_NAME,BEAT_OF_OCCURRENCE,PHOTOS_TAKEN_I,STATEMENTS_TAKEN_I,DOORING_I,WORK_ZONE_I,WORK_ZONE_TYPE,WORKERS_PRESENT_I,NUM_UNITS,MOST_SEVERE_INJURY,INJURIES_TOTAL,INJURIES_FATAL,INJURIES_INCAPACITATING,INJURIES_NON_INCAPACITATING,INJURIES_REPORTED_NOT_EVIDENT,INJURIES_NO_INDICATION,INJURIES_UNKNOWN,CRASH_HOUR,CRASH_DAY_OF_WEEK,CRASH_MONTH,LATITUDE,LONGITUDE,LOCATION
bacbcf3442c8f6c595c790a2ed777880ba043e3df354e8640f7f3fc9977870f5906f7e6c88b663ce781e4111586c6f29217afbb4cad80f2142c236895887198e,JB465068,,10/06/2018 03:50:00 PM,30,STOP SIGN/FLASHER,FUNCTIONING PROPERLY,RAIN,DAYLIGHT,PEDESTRIAN,NOT DIVIDED,0
@stevevance
stevevance / red_line_extension.geojson
Created March 5, 2021 03:05
Bike route for Old Fashioned Donuts and Red Line Extension
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stevevance
stevevance / array_trim.sql
Last active March 8, 2025 23:43
Trim the string elements of an array in PostgreSQL (wrap this function around an array or another function that returns an array, like string_to_array).
CREATE OR REPLACE FUNCTION array_trim(text[])
RETURNS text[]
AS
$$
DECLARE
text ALIAS FOR $1;
retVal text[];
BEGIN
FOR I IN array_lower(text, 1)..array_upper(text, 1) LOOP
retVal[I] := trim(text[I]);