Skip to content

Recalculate & Show Building Ward Data + Ward Pages#178

Merged
vkoves merged 34 commits intomainfrom
find-building-ward-data
Jun 6, 2025
Merged

Recalculate & Show Building Ward Data + Ward Pages#178
vkoves merged 34 commits intomainfrom
find-building-ward-data

Conversation

@wangbertha
Copy link
Copy Markdown
Collaborator

@wangbertha wangbertha commented Apr 2, 2025

Description

This pull request calculates and adds Ward number to the data that is used for the individual buildings pages (Issue #56).

Requesting review on standalone functions and call point in the data pipeline before next steps (next steps are in the subsequent comment).

Fixes #56

Testing Instructions

The function to add Ward number may be tested by running add_ward_numbers.py.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@wangbertha
Copy link
Copy Markdown
Collaborator Author

Next Steps:

  1. Run through data pipeline to update building information.
  2. Display Ward number data in the frontend.
  3. Add filters by Ward.
  4. Consider adding resource links for users to contact their alderpeople.

@wangbertha wangbertha requested a review from vkoves April 2, 2025 19:33
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 2, 2025

Deploy Preview for radiant-cucurucho-d09bae ready!

Name Link
🔨 Latest commit 2d72532
🔍 Latest deploy log https://app.netlify.com/projects/radiant-cucurucho-d09bae/deploys/68435fbe1065e00008cdc282
😎 Deploy Preview https://deploy-preview-178--radiant-cucurucho-d09bae.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Owner

@vkoves vkoves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangbertha - this looks good, and I support keeping this a separate PR that just adds the corrected wards! I have a few notes, but the other big one is let's add some tests! I'd think it could be super simple, like confirming three known buildings get mapped to the right wards.

Comment thread src/data/scripts/wards_buildings.py Outdated
Comment thread src/data/scripts/wards_buildings.py Outdated
Comment thread src/data/scripts/wards_buildings.py Outdated
Comment thread requirements.txt Outdated
Comment thread src/data/scripts/process_data.py Outdated
Comment thread src/data/scripts/wards_buildings.py Outdated
@wangbertha
Copy link
Copy Markdown
Collaborator Author

In-Progress: Adding tests, and resolving data discrepancies!

@vkoves vkoves self-assigned this Apr 25, 2025
@wangbertha
Copy link
Copy Markdown
Collaborator Author

@vkoves I integrated the 3 methods to find Ward numbers into the data pipeline. I think we should use the City Geocoding method, so I added tests that run against that method.

@wangbertha wangbertha requested a review from vkoves May 27, 2025 22:42
Comment thread src/templates/Ward.vue

// TODO: Figure out a way to get metaInfo working without any
// https://github.com/xerebede/gridsome-starter-typescript/issues/37
@Component<any>({

Check warning

Code scanning / ESLint

Disallow the `any` type Warning

Unexpected any. Specify a different type.
Copy link
Copy Markdown
Owner

@vkoves vkoves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangbertha - great work! I poked a few buildings and the ward numbers seemed sound, so I helped you out on the front-end and added the ward number to each building, and made a quick "Ward" template, so that you can see buildings for each ward 🎉

This was a highly requested featured by our advocates and should help us target specific alderman!

Building Page Ward Page
image Screenshot from 2025-06-01 16-26-58

My asks:

  1. Now that you've tried the three different approaches, can we trim down the final output to one, and maybe call it WardCalculated or something? (to make clear it's not what comes from the raw data)
  2. I appreciate you adding README's to your files, but should you add anything to the overall README to make sure folks re-run your code when there's a new data update?

Alternatively, we could also just call it Ward, since the city field is called Wards, and the final data is ultimately for us 🤷🏻‍♂️

Comment thread eslint.config.mjs
Comment thread src/data/scripts/building-coordinates/README.md Outdated
@vkoves vkoves changed the title Find building ward data Recalculate & Show Building Ward Data + Ward Pages Jun 1, 2025
@wangbertha
Copy link
Copy Markdown
Collaborator Author

@vkoves Thank you for the review! I have made your requested updates. I called the final column Ward (fyi- it looks like the most recent benchmarking dataset this year doesn't even include the Wards column!). In the frontend, I updated any instances of WardByCityGeocoder to Ward to match this.

I also updated the individual building page to display Not found if the City Geocoder did not return a value.

Let me know if any other changes would be necessary or helpful!

@wangbertha wangbertha requested a review from vkoves June 4, 2025 05:35
Comment thread src/data/scripts/add_ward_numbers.py Outdated
elif building['WardByGMapsCoordinates'] == building['WardByGMapsCoordinates']:
return -4
return -5
# def find_ward_number_by_obj_coordinates(ward_shapes: pd.DataFrame, coordinatesStr: str) -> int | None:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangbertha - should this code just be deleted? We shouldn't merge in large blocks of commented code

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can delete these! Do you think I should also remove the source files for the methods we are not using? Those would be BuildingCoordinates.csv and WardShapes.csv.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the shapes might be useful (for future rendering) but I trust your judgement on that. It's fine if we have unused code if we have a plan to use it in the future, but you can always come back to this PR and retrieve code if you need it again!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! I'll remove them for now, so that if they are used later, they will be associated with the PR that uses them for rendering. Plus, it doesn't take long to add them!

@wangbertha wangbertha requested a review from vkoves June 6, 2025 21:41
Comment thread README.md

2. To then process a new CSV file (at `src/data/source/ChicagoEnergyBenchmarking.csv`), you need to run the following command:
2. If you update the [Chicago Energy Benchmarking Data](https://data.cityofchicago.org/Environment-Sustainable-Development/Chicago-Energy-Benchmarking/xq83-jr8c/about_data)
(`src/data/source/ChicagoEnergyBenchmarking.csv`), you need to update `src/data/source/CityGeocoder.xlsx` by following the
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this earlier, so we can handle it next time, but why did this end up being an XLSX file? I swear it was a CSV before, because I checked it 🤔

I think for the follow up it would also be helpful to explain what that file is. I also notice in the geocode process that it takes the whole file and a manual process, but since buildings don't shift over time, we probably want to make a process that only geocodes new addresses. That can be a future improvement though!

Copy link
Copy Markdown
Owner

@vkoves vkoves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had one last comment, but not going to block this, especially with EcoFest tomorrow! I don't think I fully understood how the geocode process works, but now that I do I have some thoughts for future improvement

@vkoves vkoves merged commit 4906273 into main Jun 6, 2025
7 checks passed
@vkoves vkoves deleted the find-building-ward-data branch June 6, 2025 22:29
@wangbertha
Copy link
Copy Markdown
Collaborator Author

The typo you caught earlier was actually a typo for another ward method! The City Geocoder takes in and outputs an Excel file. There might be a way to pull the data through an API call (perhaps as used in the WardWise project), where we might be able to reduce manual steps even more.

Agreed that we can optimize the script further to just query new buildings!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Figure Out A Way to Get Ward Data For All Buildings

4 participants