-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIncentives_in_TIFs.qmd
1174 lines (933 loc) · 41.3 KB
/
Incentives_in_TIFs.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Incentive Projects in TIFs"
format:
html:
code-fold: true
toc: true
toc-location: left
tbl-cap-location: margin
fig-cap-location: top
df-print: paged
---
**Data Preparation**
```{r setup, warning = FALSE, output = FALSE}
library(tidyverse)
library(DT)
library(flextable) # for exporting to word or PDF files. Kable does not do that
library(sf)
library(httr)
library(jsonlite)
library(ggpattern)
knitr::opts_chunk$set(warning = FALSE, message = FALSE, error = TRUE)
set_flextable_defaults(theme_fun = theme_vanilla,
padding = 2,
line_spacing = 1,
big.mark = ",",
)
# keypins <- read_csv("Output/all_keypins.csv")
options(DT.options = list())
####Customize features and interactivity of table
#create a list of options used to format the DT table
my.options <- list(autoWidth = FALSE, #smart width handling
searching = TRUE, #search box above table
ordering = TRUE, #whether columns can be sorted
#lengthChange = FALSE, #ability to change number rows shown on page in table
#lengthMenu = FALSE, #options lengthChange can be changed to
pageLength = FALSE, #initial number of rows per page of table
paging = TRUE, #whether to do pagination
info = TRUE) #notes whether or not table is filtered
# link to the API output as a JSON file
muni_shp <- read_sf("https://gis.cookcountyil.gov/traditional/rest/services/politicalBoundary/MapServer/2/query?outFields=*&where=1%3D1&f=geojson")
forests <- read_sf("https://services2.arcgis.com/I5Or36sMcO7Y9vQ3/arcgis/rest/services/Forest_Preserve_Nature_Preserves/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson")
```
## Create Project ID
### Board of Review Appeals Data
Pulls appeal data from the Cook County Data Portal. CSV file was created using data from May 2024. Property classes had extra zeros padding the right side of the class so an additional data cleaning step was done after pulling the data.
After the second filter step to fix the class variable and filter the remaining residential properties out, there are 780K observations.
```{r getBORappeals, eval=FALSE}
base_url <- "https://datacatalog.cookcountyil.gov/resource/7pny-nedm.json?$where=class > 399"
bor <- GET(
base_url,
query = list(
`$select` = paste0(c("pin", "township_code", "tax_year",
"class", "majorclass", "changereason",
"changereasondescription",
"appealid", "appellant"
),
collapse = ","),
`$limit` = 6000000L
)
)
bor <- fromJSON(rawToChar(bor$content))
## class had extra zeros padding the right side so keep first 3 digits that are the actual property class
bor <- bor %>%
mutate(
class_bor = str_sub(class, 1,3)) %>%
filter(class > 399) ## filters out any property class below 400
bor <- bor %>%
mutate(project_id = str_extract(appealid, "[^.]+"))
write_csv(bor, "Output/borappeals.csv")
```
```{r}
#| label: tbl-getBORappeals2
#| tbl-cap: "Board of Review Appeal Data - Grouped by appellant and project ID. Project ID is created from the `appealid` variable used by the BoR. The `appealid` appears to group PINs by the digits before the decimal point."
bor <- read_csv("Output/borappeals.csv") %>%
mutate(project_appellant = paste(project_id, sep = "-", appellant))
# bor %>%
# group_by(tax_year, project_id, appellant) %>%
# summarize(pincount = n(),
# pins = list(pin)) %>%
# filter(pincount > 1) %>%
# arrange(desc(tax_year)) %>%
# head() %>%
# datatable(rownames = FALSE)
#
# bor %>%
# group_by(tax_year, project_id) %>%
# summarize(pincount = n(),
# appellant = list(unique(appellant)),
# pins = list(pin)) %>%
# filter(pincount > 1) %>%
# arrange(desc(tax_year)) %>%
# head() %>%
# datatable(rownames = FALSE)
```
For the Archived Parcel Universe:
- 13,000+ KeyPINs have more than 1 PIN associated with them.
- 11,849 when grouping by keypin and mailing name. But that is probably due to a bunch of keypins having mailing names that do not match completely so when grouped this way, they now have only 1 PIN associated with the keypin, which was filter out.
```{r}
parcuniverse_keypins <- readxl::read_xlsx("./Inputs/parceluniverse_keypins_20240725.xlsx",
sheet = "keypins_20240725") %>%
mutate(pin14 = str_pad(as.character(pin), width = 14, side = "left", pad = "0"),
keypin = str_pad(as.character(proration_key_pin), width = 14, side = "left", pad = "0"),
pin10 = str_sub(pin14,1,10),
pin7 = str_sub(pin14,1,7), .before = "pin",) %>%
select(-c(pin_7dig, pin, Column1)) %>%
filter(class != "EX")
puni_keypins <- parcuniverse_keypins %>%
select(pin14,
puni_keypin = keypin,
proration_rate2022 = proration_rate,
mailing_name2022 = mailing_name)
parcuniverse_keypins %>%
group_by(keypin
#, mailing_name
) %>%
summarize(pincount = n(),
class = mean(as.numeric(class), na.rm=TRUE),
has_incent = sum(ifelse(as.numeric(between(class, 600, 899)), 1, 0))) %>%
filter(pincount > 1) %>%
arrange(desc(has_incent), desc(pincount))
# parcuniverse_keypins %>% filter(is.na(mailing_name)) # 21,612 keypins
# parcuniverse_keypins %>% distinct(keypin) # 21,612 keypins
```
```{r}
#| label: tbl-borprojectpins
#| tbl-cap: "Uses first occurance of the an appeal id and the appealant name to create project IDs for each PIN. This deal with PINS that appealed multiple time and makes each PIN a unique occurance. Takes numbers for athe decimal point in `appealid to create project ID. Uses Board of Review Appeals data from the Cook County Data Portal. Counts number of times each PIN appealed its valuation. 102,619 PINs from BoR data (downloaded May 2024)."
bor_pins <- bor %>%
group_by(pin) %>%
arrange(desc(tax_year)) %>%
summarize(pin = first(pin),
class_bor = list(class),
taxyear_appealed = list(tax_year),
appellant = first(appellant),
project_id = first(project_id),
timesappealed = n() ) %>%
mutate(proj_appeallant = paste(project_id, "-", appellant))
#46,250 distinct projects based on IDs
# projects <- bor_pins %>% distinct(project_id)
#38,808 distinct appellant names
# appellants <- bor_pins %>% distinct(appellant)
# 48,993 distinct project id-appellant combinations
projects_appellant <- bor_pins %>%
distinct(project_id, appellant)
```
### Joined Pin Data
Pull in the joined pin and exemption data for 2022. Extracted from PTAXSIM. See `0_joined_PIN_data_2022.qmd` for code.
```{r}
#| echo: true
#| code-fold: false
loa <- read_csv("inputs/ccao_loa.csv") %>%
filter(year == 2022)
# all pins for 2022
ptax_pins <- read_csv("Output/Dont_Upload/0_joined_PIN_data_2022.csv") %>%
mutate(class = as.numeric(class)) %>%
# # keep 500-899 class PINs
filter(#(class >= 400 & class < 900) |
between(class, 0, 199) | between(class, 400, 899)
# # and keep land PINs if we want land property owned by them too.
# (class >= 100 & class < 200)
) %>%
select(-c(propclass_1dig:av.y)) %>%
mutate(fmv = ifelse(is.na(fmv), 0, fmv)) %>%
select(-c(exe_homeowner:exe_vet_dis_ge70))
ptax_pins <- ptax_pins %>%
left_join(bor_pins) %>%
left_join(puni_keypins, by = c("pin" = "pin14")) %>%
select(proj_appeallant, puni_keypin, pin, tax_code, class, class_bor, tax_code_rate, fmv, everything()) %>%
select(-c(has_HO_exemp:has_DV_exemp))
ptax_pins %>%
filter(is.na(proj_appeallant) & is.na(puni_keypin) & class < 200)
ptax_pins <- ptax_pins %>%
filter((!is.na(proj_appeallant) & !is.na(puni_keypin)) | class > 200)
```
### Methodology Worksheet Project IDs (from Data Portal: commercial valuation dataset)
82,957 distinct keypins from `all_keypins` file. (Made from commercial valuation dataset on the Data Portal.)
46,213 distinct project ids using the Board of Review appeal ids
```{r}
#| echo: true
#| code-fold: false
# temporary work-around until we have full keypin list:
proj_xwalk <- read_csv("Output/all_keypins.csv")
# all commercial valuation properties but made with very unreliable data from commercial valuation dataset.
# 82K+ distinct keypins from all_keypins file
# proj_xwalk %>% distinct(keypin)
# combine project IDs to PINs:
ptax_pins <- ptax_pins %>% left_join(proj_xwalk, by = "pin")
project_sums <- ptax_pins %>%
mutate(actual_keypin = ifelse(is.na(proj_appeallant), puni_keypin, proj_appeallant))%>%
mutate(actual_keypin = ifelse(is.na(actual_keypin), keypin, actual_keypin))%>%
group_by(actual_keypin) %>%
summarize(
fmv = sum(fmv),
tax_code = mean(tax_code),
final_tax_to_dist = sum(final_tax_to_dist),
pin_classes = list(unique(class)),
incent_pins = sum(ifelse(class >= 600 & class < 900, 1, 0)),
project_pins = n()
)
project_sums
# create tc_muninames from helper file:
source("scripts/helper_tc_muninames_2022.R")
tc_muninames <- tc_muninames %>% select(-year)
# add muni names by joining tax code info:
ptax_pins <- ptax_pins %>%
mutate(tax_code_num = as.character(tax_code_num)) %>%
left_join(tc_muninames)
# original class_dict variables already in 0_joined data
# but I do want the new-ish variables I created to be brought in:
class_dict <- read_csv("./Necessary_Files/class_dict_expanded.csv") %>%
select(class_code, comparable_props, Alea_cat, incent_prop)
ptax_pins <- ptax_pins %>%
left_join(class_dict, by = c("class" = "class_code")) %>%
mutate(clean_name = ifelse(is.na(clean_name), "0_Unincorporated", clean_name))
```
```{r}
#| label: tbl-createbothids2
#| tbl-cap: "Incentive Properties only. Count of PINs in project ID (using `both_ids`). both_ids is created from using the BoR appeal ids as the default group ID. Then if a PIN in ptaxsim doesn't match to a Board of Review appeal PIN, project IDs from the commercial valuation data set are used."
newproject_pinlist <- ptax_pins %>%
mutate(actual_keypin = ifelse(is.na(proj_appeallant), puni_keypin, proj_appeallant)) %>%
mutate(actual_keypin = ifelse(is.na(actual_keypin), keypin, actual_keypin)) %>%
select(pin, actual_keypin)
ptax_pins <- ptax_pins %>%
mutate(actual_keypin = ifelse(is.na(proj_appeallant), puni_keypin, proj_appeallant)) %>%
mutate(actual_keypin = ifelse(is.na(actual_keypin), keypin, actual_keypin)) %>%
mutate(both_ids = actual_keypin)
ptax_pins %>%
group_by(both_ids) %>%
summarize(pincount = n()) %>% arrange(desc(pincount))
ptax_pins %>%
distinct(both_ids)
# table_list <- ptax_pins %>%
# filter(class > 599) %>%
# group_by(both_ids) %>%
# summarize(pincount = n(),
# pin_list = (list(unique(pin))),
# class_list = (list(unique(class))),
# appellant = ((list(unique(appellant)))) ) %>%
# arrange(desc(pincount))
#
# table_list %>% datatable(rownames = FALSE)
```
```{r}
#| label: tbl-Aleacats-inTIFs
#| tbl-cap: "All nonResidential PINs Types. Count of PINs in project ID (using `both_ids`). both_ids is created from using the BoR appeal ids as the default group ID. Then if a PIN in ptaxsim doesn't match to a Board of Review appeal PIN, project IDs from the commercial valuation data set are used."
table <- ptax_pins %>%
group_by(Alea_cat) %>%
summarize(proptype_pincount = n(),
projects = n_distinct(both_ids),
av_incent = sum(ifelse(incent_prop == "Incentive", av, 0)),
av_nonincent = sum(ifelse(incent_prop == "Non-Incentive", av, 0)),
av=sum(av),
incentpins_inTIF = sum(ifelse(in_tif == 1 & incent_prop == "Incentive", 1, 0)),
pins_inTIF = sum(in_tif, na.rm=TRUE),
fmv = sum(fmv, na.rm=TRUE)
) %>%
mutate(
incent_av_adj = 2.5*av_incent) %>%
mutate(
total_av_adjusted = av_incent*2.5 + av_nonincent,
pct_incent = incent_av_adj / total_av_adjusted) %>%
select(-c(av_incent, av_nonincent, incent_av_adj))
flextable(table) %>%
# set_caption("Totals for Cook County") %>%
set_header_labels(Alea_cat = "Property Type", proptype_pincount = 'PINs', projects = "Project IDs", av = ' Taxable AV') %>%
set_table_properties( layout = "autofit", width = .75)
```
```{r}
#| label: tbl-summarytable-commercialandindustrialPINs
#| tbl-cap: "Commercial and Industrial PINs only (500 and higher, excludes nonprofit properties). Count of PINs in project ID (using `both_ids`). both_ids is created from using the BoR appeal ids as the default group ID. Then if a PIN in ptaxsim doesn't match to a Board of Review appeal PIN, project IDs from the commercial valuation data set are used."
com_ind_projects <- ptax_pins %>%
group_by(both_ids) %>%
arrange(both_ids, class) %>%
mutate(min_class = first(class),
max_class = last(class)) %>%
filter(max_class > 499) %>%
ungroup()
table <- com_ind_projects %>%
group_by(Alea_cat) %>%
summarize(proptype_pincount = n(),
projects = n_distinct(both_ids),
av_incent = sum(if_else(incent_prop == "Incentive", av, 0)),
av_nonincent = sum(ifelse(incent_prop == "Non-Incentive", av, 0)),
# av_adjusted=sum(ifelse(between(class, 600, 899), av*2.5, av)),
av=sum(av),
fmv =sum(fmv, na.rm=TRUE),
pins_inTIF = sum(in_tif, na.rm=TRUE)
) %>%
mutate(
incent_av_adj = 2.5*av_incent ) %>%
mutate(
total_av_adjusted = incent_av_adj + av_nonincent,
pct_incent = incent_av_adj / total_av_adjusted) %>%
select(-c(av_incent, av_nonincent))
flextable(table) %>%
# set_caption("Totals for Cook County") %>%
set_header_labels(Alea_cat = "Property Type", proptype_pincount = 'PINs', projects = "Project IDs", av = ' Current Taxable AV') %>%
set_table_properties( layout = "autofit", width = .75)
```
```{r}
#| label: tbl-summarytable-commercialandindustrial-incentivePINs
#| tbl-cap: "Commercial and Industrial Incentive PINs only (600 and higher, excludes nonprofit properties). Count of PINs in project ID (using `both_ids`). both_ids is created from using the BoR appeal ids as the default group ID. Then if a PIN in ptaxsim doesn't match to a Board of Review appeal PIN, project IDs from the commercial valuation data set are used."
incentive_pins2022 <- ptax_pins %>%
group_by(both_ids) %>%
arrange(both_ids, class) %>%
mutate(min_class = first(class),
max_class = last(class)) %>%
filter(max_class > 599 & max_class < 900) %>%
ungroup()
table <- incentive_pins2022 %>%
group_by(Alea_cat) %>%
summarize(proptype_pincount = n(),
projects = n_distinct(both_ids),
av_incent = sum(if_else(incent_prop == "Incentive", av, 0)),
av_nonincent = sum(ifelse(incent_prop == "Non-Incentive", av, 0)),
# av_adjusted=sum(ifelse(between(class, 600, 899), av*2.5, av)),
av=sum(av),
fmv =sum(fmv, na.rm=TRUE),
pins_inTIF = sum(in_tif, na.rm=TRUE)
) %>%
mutate(
incent_av_adj = 2.5*av_incent ) %>%
mutate(
total_av_adjusted = incent_av_adj + av_nonincent,
pct_incent = incent_av_adj / total_av_adjusted) %>%
select(-c(av_incent, av_nonincent))
flextable(table) %>%
# set_caption("Totals for Cook County") %>%
set_header_labels(Alea_cat = "Property Type", proptype_pincount = 'PINs', projects = "Project IDs", av = ' Current Taxable AV') %>%
set_table_properties( layout = "autofit", width = .75)
```
> renaming the both_ids variable to keypin to avoid changing all the code below.
```{r}
#| code-fold: false
ptax_pins <- ptax_pins %>%
mutate(keypin = both_ids)
```
## Create TIF vectors
```{r}
# TIF distributions will include all the unique tax codes that make up
# a TIF
# has eav values for each tax code
tif_distrib <- DBI::dbGetQuery(
ptaxsim_db_conn,
glue_sql("
SELECT *
FROM tif_distribution
WHERE year = 2022
",
.con = ptaxsim_db_conn
)
)
# has same number of pins as method used above but way faster.
tif_pins <- DBI::dbGetQuery(
ptaxsim_db_conn,
glue::glue_sql("
SELECT DISTINCT *
FROM pin
WHERE tax_code_num IN ({unique(tif_distrib$tax_code_num)*})
AND year = 2022
",
.con = ptaxsim_db_conn
)
)
```
```{r}
bound_tif <- st_read(paste0(
"https://opendata.arcgis.com/api/v3/datasets/",
"8aeb00520c544aafb9a22510465c679d_18/downloads/",
"data?format=geojson&spatialRefId=4326&where=1%3D1"
), quiet = TRUE)
# bound_tif %>%
# ggplot() +
# geom_sf(data = bound_tif, aes(geometry = geometry#, fill = project_count
# ), color = "black") +
# theme_void()
```
### TIF pins and Lookup_pin() command.
```{r}
ptax_pins <- ptax_pins %>%
# create a dummy variable for if the pin is located in a tax_code that is within a tif
mutate(in_tif = ifelse(pin %in% tif_pins$pin, 1,0))
incentive_pins2022 <- incentive_pins2022 %>%
# create a dummy variable for if the pin is located in a tax_code that is within a tif
mutate(in_tif = ifelse(pin %in% tif_pins$pin, 1,0))
```
Amount of EAV in and outside of TIF areas:
> This is the EAV before exemptions are subtracted. Comes from lookup_pin() command.
Individual properties are summed together within the municipality.
```{r}
#| label: tbl-allprops-eavinandoutTIF
#| tbl-cap: "All non-residential properties in and out of TIFs in Cook County. Sums EAV."
EAV_inandout_TIF <- ptax_pins %>%
group_by(clean_name,
in_tif) %>%
summarise(eav = sum(eav, na.rm=TRUE)) %>%
pivot_wider(names_from = in_tif, values_from = eav
)%>%
mutate(#total = `0`+`1`
total = ifelse(is.na(`1`), `0`, `0`+`1`)) %>%
rename(
"Taxable EAV" = `0`,
"TIF Increment" = `1`,
"Total EAV before exemptions" = total)
EAV_inandout_TIF %>% datatable(rownames = FALSE)
```
```{r}
#| label: tbl-incentiveprops-eavinandoutTIF
#| tbl-cap: "Incentive non-residential properties in and out of TIFs in Cook County. Sums EAV."
EAV_inandout_TIF <- incentive_pins2022 %>%
group_by(clean_name,
in_tif) %>%
summarise(eav = sum(eav, na.rm=TRUE)) %>%
pivot_wider(names_from = in_tif, values_from = eav
)%>%
mutate(#total = `0`+`1`
total = ifelse(is.na(`1`), `0`, `0`+`1`)) %>%
rename(
"Taxable EAV" = `0`,
"TIF Increment" = `1`,
"Total EAV before exemptions" = total)
EAV_inandout_TIF %>% datatable(rownames = FALSE)
```
```{r}
#| label: tbl-allprops-FMVinandoutTIF
#| tbl-cap: "All non-residential properties in and out of TIFs in Cook County. Sums FMV."
FMV_inandout_TIF <- ptax_pins %>%
group_by(clean_name,
in_tif) %>%
summarise(fmv = sum(fmv, na.rm=TRUE)) %>%
pivot_wider(names_from = in_tif, values_from = fmv
)%>%
mutate(#total = `0`+`1`
total = ifelse(is.na(`1`), `0`, `0`+`1`)) %>%
rename(
"Taxable FMV (Before Exemptions)" = `0`,
"TIF Increment" = `1`,
"Total FMV before exemptions" = total)
FMV_inandout_TIF %>% datatable(rownames = FALSE) %>%
formatCurrency(c('Taxable FMV (Before Exemptions)', 'TIF Increment', 'Total FMV before exemptions'), digits = 0)
```
```{r}
#| label: tbl-incentiveprops-FMVinandoutTIF
#| tbl-cap: "All incentive non-residential properties in and out of TIFs in Cook County. Sums FMV. FMV is the AV / level of assessment."
FMV_inandout_TIF <- incentive_pins2022 %>%
group_by(clean_name,
in_tif) %>%
summarise(fmv = sum(fmv, na.rm=TRUE)) %>%
pivot_wider(names_from = in_tif, values_from = fmv
)%>%
mutate(#total = `0`+`1`
total = ifelse(is.na(`1`), `0`, `0`+`1`)) %>%
rename(
"Taxable FMV (Before Exemptions)" = `0`,
"TIF Increment" = `1`,
"Total FMV before exemptions" = total)
FMV_inandout_TIF %>% datatable(rownames = FALSE) %>%
formatCurrency(c('Taxable FMV (Before Exemptions)', 'TIF Increment', 'Total FMV before exemptions'), digits = 0)
```
```{r}
#| label: tbl-cooklevel-eavinandoutTIF
#| tbl-cap: "Cook County non-residential EAV totals in and out of TIF"
ptax_pins %>%
group_by(
in_tif) %>%
summarise(eav = sum(eav, na.rm=TRUE)) %>%
pivot_wider(names_from = in_tif, values_from = eav
)%>%
mutate(
total = ifelse(is.na(`1`), `0`, `0`+`1`)) %>%
rename(
"Taxable EAV" = `0`,
"TIF Increment" = `1`,
"Total EAV before exemptions" = total)
```
```{r}
ptax_pins %>% group_by(clean_name, incent_prop, in_tif) %>%
summarize(pins = n(),
projects = n_distinct(keypin),
# av_incent = sum(ifelse(between(class, 600, 899), av*2.5, 0)),
av_adjusted = sum(ifelse(between(class, 600, 899), av*2.5, av)),
av = sum(av)
) %>% datatable(rownames = FALSE)
```
```{r}
#| label: tbl-percentofcommercialindustrialAV
#| tbl-cap: "Percentages are out of the commercial and industrial pins with and without incentive property classifications in a Muni"
table3 <- ptax_pins %>%
group_by(clean_name) %>%
mutate(muni_pins = n(),
muni_projects = n_distinct(keypin),
# av_incent = sum(ifelse(between(class, 600, 899), av*2.5, 0)),
muni_av_adjusted = sum(ifelse(between(class, 600, 899), av*2.5, av)),
muni_av = sum(av)
) %>%
ungroup() %>%
group_by(clean_name, incent_prop, in_tif, muni_pins, muni_projects, muni_av, muni_av_adjusted) %>%
summarize(pins = n(),
projects = n_distinct(keypin),
# av_incent = sum(ifelse(between(class, 600, 899), av*2.5, 0)),
av_adjusted = sum(ifelse(between(class, 600, 899), av*2.5, av)),
av = sum(av),
fmv = sum(fmv, na.rm=TRUE)
) %>%
mutate(pct_munipins = pins / muni_pins,
pct_muniprojects = projects / muni_projects,
pct_muniav = round(av / muni_av, digits =3),
pct_adjustedmuniav = round(av_adjusted / muni_av_adjusted, digits = 3)) %>%
select(clean_name, incent_prop, in_tif, pct_munipins, pct_muniprojects, pct_muniav, pct_adjustedmuniav, everything())
table3
table3 %>% filter(in_tif == 1) %>%
datatable( rownames= FALSE
) %>%
# set_caption("Totals for Cook County") %>%
# set_header_labels(Alea_cat = "Property Type", proptype_pincount = 'PINs', projects = "Project IDs", av = ' Taxable AV') %>%
set_table_properties( layout = "autofit", width = .75) %>%
formatPercentage(c('pct_munipins', 'pct_muniprojects', 'pct_muniav', 'pct_adjustedmuniav'), digits = 2)
```
# Incentive Users - Muni level
34 Municipalities do not use Incentive Classifications.
15 cross into other counties. All 15 that cross county lines do use incentive classifications.
Alsip, Bedford Park, Blue Island,Bridgeview, Riverdale, South Holland, Summit, and Worth also use "Abatements" (based on the exe_abate variable in PTAXSIM)
```{r}
#| label: tbl-countycrossers
#| column: margin
cross_county_lines <- c("030440000", "030585000", "030890000", "030320000", "031280000","030080000", "030560000", "031120000", "030280000", "030340000","030150000","030050000", "030180000","030500000","031210000")
cross_county_lines <- tc_muninames %>% filter(agency_num %in% cross_county_lines) %>% select(clean_name, agency_num) %>% distinct() %>% arrange(clean_name)
cross_county_lines <- cross_county_lines %>% left_join(muni_shp, by = c("clean_name" = "MUNICIPALITY"))
no_incentives <- ptax_pins %>%
# filter(between(class, 600, 899)) %>%
group_by(clean_name) %>%
summarize(incent_pins = sum(ifelse(between(class, 600, 899), 1, 0))) %>%
filter(incent_pins == 0) %>%
distinct(clean_name)
no_incentives <- no_incentives %>% left_join(muni_shp, by = c("clean_name" = "MUNICIPALITY"))
# saveRDS(no_incentives, "no_incentives_formap.rds")
# to use in 7_incentives.qmd file
```
```{r}
#| label: tbl-cooktotals
#| tbl-cap: "Cook County: Commercial and Industrial Fair Market Value with Incentive Classification. There is over $600 billion FMV in Cook County when including all property types. Of the $600 billion FMV in Cook County, $113 billion is from commercial and industrial property, of which $13 billion FMV has an incentive classification."
nonres_pins2022 <- ptax_pins
table <- nonres_pins2022 %>%
group_by(Alea_cat) %>%
summarize(proptype_pincount = n(),
projects = n_distinct(keypin),
av_incent = sum(ifelse(incent_prop == "Incentive", av, 0)),
fmv_incent = sum(ifelse(incent_prop == "Incentive", fmv, 0)),
av_nonincent = sum(ifelse(incent_prop == "Non-Incentive", av, 0)),
fmv_nonincent = sum(ifelse(incent_prop == "Non-Incentive", fmv, 0)),
av=sum(av),
fmv=sum(fmv, na.rm=TRUE)
) %>%
mutate(
incent_av_adj = 2.5*av_incent) %>%
mutate(
total_av_adjusted = av_incent*2.5 + av_nonincent,
pct_incent = incent_av_adj / total_av_adjusted,
pct_fmv = fmv_incent / fmv ) %>%
select(-c(av_incent, av_nonincent, incent_av_adj))
flextable(table) %>%
# set_caption("Totals for Cook County") %>%
set_header_labels(Alea_cat = "Property Type", proptype_pincount = 'PINs', projects = "Project IDs", fmv = 'FMV', av = ' Taxable AV') %>%
set_table_properties( layout = "autofit", width = .75)
```
```{r}
#| label: tbl-amount-incentivized
#| tbl-cap: "Percent of Commercial and Industrial Market Value for Assessment Purposes that has a reduced assessment rate due to incentive classification"
table2 <- nonres_pins2022 %>%
filter(Alea_cat != "Land") %>%
group_by(clean_name) %>%
summarize(pin_count = n(),
project_count = n_distinct(keypin),
av_incent = sum(ifelse(between(class, 600, 899), av*2.5, 0)),
av_adjusted = sum(ifelse(between(class, 600, 899), av*2.5, av)),
fmv_w_incent = sum(ifelse(between(class, 600, 899), fmv, 0)),
av=sum(av),
fmv =sum(fmv, na.rm=TRUE),
incent_pins_inTIF = sum(ifelse(between(class, 600, 899) & in_tif == 1, 1, 0), na.rm = TRUE),
pins_inTIF = sum(in_tif, na.rm=TRUE)
) %>%
mutate(av_incent = ifelse(av_incent == 0, NA, av_incent),
pct_incent = av_incent / av_adjusted,
pct_incent = ifelse(pct_incent == 0, NA, pct_incent),
pct_fmv = fmv_w_incent/fmv) %>%
select(-av_incent) %>%
select(clean_name, pct_incent, av, fmv, pct_fmv, av_adjusted, pin_count, project_count, pins_inTIF, incent_pins_inTIF)
datatable(table2,
rownames= FALSE,
colnames = c('Municipality' = 'clean_name', # 'Incentivized?' = 'incent_prop',
'PIN Count' = 'pin_count', 'Project Count' = 'project_count',
'Taxable AV' = 'av',
'FMV' = 'fmv', 'Pct FMV with Incentives' = 'pct_fmv',
'Assessed Market Value' = 'av_adjusted',
'Pct AV Incentivized' = 'pct_incent')
) %>%
formatCurrency(c('Taxable AV', 'Assessed Market Value', 'FMV'), digits = 0) %>%
formatPercentage(c('Pct AV Incentivized', 'Pct FMV with Incentives'), digits = 2)
```
# A map!
```{r}
# if (all(top_five_kenya_fixed_1_8$county |>
# unique() %in% correct_kenya_counties)) {
# "The cleaned counties match the expected countries"
# } else {
# "Not all of the counties have been cleaned completely"
# }
if (all(nicknames$shpfile_name |>
unique() %in% muni_shp$MUNICIPALITY)) {
"The cleaned municipality names match the expected municipality names"
} else {
"Not all of the municipalities have been cleaned completely"
}
```
```{r}
#| label: fig-pctincentivevalue-bothtypes
#| fig-cap: "Number of Commercial and Industrial Projects per Municipality. A Project is based off of distinct KeyPINs. Includes all incentive and non-incentive property classes."
table2 %>%
left_join(nicknames) %>%
filter(clean_name != "Chicago"& clean_name!="0_Unincorporated" &
!is.na(clean_name)) %>%
full_join(muni_shp, by = c("shpfile_name" = "MUNICIPALITY")) %>%
ggplot() +
geom_sf(aes(geometry = geometry, fill = project_count), color = "black", alpha = 0.3) +
theme_void() +
theme(axis.ticks = element_blank(), axis.text = element_blank())+
scale_fill_steps2(
high = "brown", low = "black",
show.limits = TRUE,
# nice.breaks=FALSE,
na.value = "gray60",
name = "Number of Projects",
) +
geom_sf_pattern(data = no_incentives, aes(geometry = geometry), pattern = 'crosshatch', pattern_spacing = 0.015, pattern_density = 0.1, fill = "white", alpha = .5, color = 'gray70')+
geom_sf_pattern(data = forests, aes(geometry = geometry), pattern_spacing = 0.015, pattern_density = 0.1, fill = "white", alpha = .5, color = 'darkgreen')+
geom_sf(data = bound_tif, aes(geometry = geometry#, fill = project_count
), color = "black", alpha = 0.5, fill ="orange")
```
```{r}
#| label: fig-incentivePINsinTIFS-counts
#| fig-cap: "Number of Commercial and Industrial INCENTIVE PINs within a TIF per Municipality. Chicago and Markham both have around 600 incentive pins in TIFs and are exclude from this map to avoid washing out other municipalities."
table2 %>%
filter(clean_name != "Chicago" & clean_name != "Markham" &
clean_name != "0_Unincorporated" & !is.na(clean_name) ) %>%
left_join(nicknames) %>%
full_join(muni_shp, by = c("shpfile_name" = "MUNICIPALITY")) %>%
ggplot() +
geom_sf(aes(geometry = geometry, fill = incent_pins_inTIF), color = "black") +
theme_void() +
theme(axis.ticks = element_blank(), axis.text = element_blank())+
scale_fill_steps2(
high = "brown", low = "black",
show.limits = TRUE,
nice.breaks=FALSE,
na.value = "gray50",
name = "Number of Incent\nPINs in TIFs",
) +
geom_sf_pattern(data = no_incentives, aes(geometry = geometry), pattern = 'crosshatch', pattern_spacing = 0.015, pattern_density = 0.1, fill = "white", alpha = .5, color = 'gray70')+
# geom_sf_pattern(data = forests, aes(geometry = geometry), pattern_spacing = 0.015, pattern_density = 0.1, fill = "white", alpha = .5, color = 'darkgreen')+
geom_sf(data = bound_tif, aes(geometry = geometry), color = "black", alpha = 0.5, fill ="orange")
```
```{r}
#| label: fig-pinsInTIF
#| fig-cap: "Number of PINs (all class types) within a TIF, per Municipality. Excludes Chicago (which has nearly 29K PINs located in TIFs)"
table2 %>%
filter(clean_name != "Chicago") %>%
filter(clean_name != "0_Unincorporated") %>%
left_join(nicknames) %>%
full_join(muni_shp, by = c("shpfile_name" = "MUNICIPALITY")) %>%
ggplot() +
geom_sf(aes(geometry = geometry, fill = pins_inTIF), color = "black") +
theme_void() +
theme(axis.ticks = element_blank(), axis.text = element_blank())+
scale_fill_steps2(
high = "brown", low = "black",
show.limits=TRUE,
nice.breaks=FALSE,
na.value = "gray60",
name = "Number of PINs in TIF",
) +
geom_sf_pattern(data = no_incentives, aes(geometry = geometry), pattern = 'crosshatch', pattern_spacing = 0.015, pattern_density = 0.1, fill = "white", alpha = .5, color = 'gray70')+
geom_sf(data = bound_tif, aes(geometry = geometry#, fill = project_count
), color = "black", alpha = 0.5, fill ="orange")
```
```{r}
#| label: fig-pinspertif-onlychicago
#| fig-cap: Number of PINs with incentive property class that are also in a TIF. Chicago only, summarized by assessor neighborhoods.
NBHs <- read_sf("https://datacatalog.cookcountyil.gov/resource/pcdw-pxtg.geojson")
nbh_sum <- read_csv("./Output/ptaxsim_nbh_summary_2022_20240727.csv") %>%
mutate(nbhd_code = as.character(nbhd_code)) %>%
mutate(township = str_sub(nbhd_code, 1, 2),
)
nbh_MC <- read_csv("Output/ptaxsim_nbh_MC_summary_2022.csv")
nbh_sum %>%
filter(triad_name == "City") %>%
left_join(NBHs, by = c("nbhd_code" = "town_nbhd")) %>%
ggplot() +
geom_sf(aes(geometry = geometry, fill = PC_incents_inTIFs), color = "black") +
theme_void() +
theme(axis.ticks = element_blank(), axis.text = element_blank())+
scale_fill_steps2(
high = "brown", low = "black",
show.limits=TRUE,
nice.breaks=FALSE,
na.value = "gray50",
name = "Number of Incent\nPINs in TIF",
) +
geom_sf(data = bound_tif, aes(geometry = geometry#, fill = project_count
), color = "black", alpha = 0.5, fill ="orange")
```
```{r}
#| label: fig-incentpinspertif
#| fig-cap: Number of PINs with incentive property class that are also in a TIF. Summarized by assessor neighborhoods. Excludes the Amazon warehouse located in Markham which has over 600 PINs associated with it."
nbh_sum %>%
filter(PC_incents_inTIFs < 500) %>%
mutate(PC_incents_inTIFs = ifelse(PC_incents_inTIFs == 0, NA, PC_incents_inTIFs))%>%
left_join(NBHs, by = c("nbhd_code" = "town_nbhd")) %>%
ggplot() +
geom_sf(aes(geometry = geometry, fill = PC_incents_inTIFs), color = "black") +
theme_void() +
theme(axis.ticks = element_blank(), axis.text = element_blank())+
scale_fill_steps2(
high = "brown", low = "black",
show.limits=TRUE,
nice.breaks=FALSE,
na.value = "gray50",
name = "Number of Incent\nPINs in TIF",
) +
geom_sf(data = bound_tif, aes(geometry = geometry#, fill = project_count
), color = "black", alpha = 0.5, fill ="orange")
```
```{r}
#| label: fig-nbhfmv-onlychicago
#| fig-cap: Only Chicago. All non-residential FMV on left and incentive PIN FMV located in TIFs on right.
#| layout-ncol: 2
nbh_sum %>%
filter(triad_name == "City") %>%
left_join(NBHs, by = c("nbhd_code" = "town_nbhd")) %>%
ggplot() +
geom_sf(aes(geometry = geometry, fill = (fmv_industrial+fmv_commercial)), color = "black") +
theme_void() +
theme(axis.ticks = element_blank(), axis.text = element_blank())+
scale_fill_steps2(
high = "brown", low = "black",
show.limits=TRUE,
nice.breaks=FALSE,
na.value = "gray50",
name = "FMV",
labels = scales::dollar
) +
geom_sf(data = bound_tif, aes(geometry = geometry
), color = "black", alpha = 0.5, fill ="orange")
nbh_sum %>%
filter(triad_name == "City") %>%
left_join(NBHs, by = c("nbhd_code" = "town_nbhd")) %>%
ggplot() +
geom_sf(aes(geometry = geometry, fill = fmv_incents_inTIF), color = "black") +
theme_void() +
theme(axis.ticks = element_blank(), axis.text = element_blank())+
scale_fill_steps2(
high = "brown", low = "black",
show.limits=TRUE,
nice.breaks=FALSE,
na.value = "gray50",
name = "FMV",
labels = scales::dollar
) +
geom_sf(data = bound_tif, aes(geometry = geometry#, fill = project_count
), color = "black", alpha = 0.5, fill ="orange")
```
```{r}
#| label: fig-industrial-commercial-fmv
#| layout-ncol: 2
#| column: page
#| fig-cap:
#| - "Pct of Industrial FMV that \nhas Incentive Classification"
#| - "Pct of Commercial FMV that \nhas Incentive Classification"
#|
nonres_pins2022 %>%
filter(Alea_cat == "Industrial") %>%
filter(clean_name != "0_Unincorporated") %>%