Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clustering member data by political geographies #28

Conversation

janbaykara
Copy link
Member

@janbaykara janbaykara commented Mar 18, 2024

This PR provides statistical data on member lists at the regional / constituency / council / ward levels, dependent on the user's current zoom, so that we are always providing some kind of insight for the current view.

As part of this work, the codebase now ingests Region, Constituency and Ward geographies for the whole of the UK, and in PostGIS format unlike before.

The scene is set for geography explorer panels and other interactive map features.

Screenshot 2024-03-19 at 18 24 29 Screenshot 2024-03-19 at 18 24 36 Screenshot 2024-03-19 at 18 24 41

Motivation

Displayed member data was previously scattered across the map like a grain truck that's tipped over onto the road.

Screenshot 2024-03-18 at 18 47 05

How Can It Be Tested?

  1. Re-build the dev container if you haven't already, as we've switched to PostGIS
  2. Import the required geo data:
    • python manage.py import_areas
    • python manage.py import_regions
    • python manage.py import_wards
  3. Connect a data source of the type Member - make sure it has postcodes!
  4. Make a report and add a map layer via the data configuration option in the top left
  5. As you zoom far to near, you should see geographical regions and their aggregate counts.
  6. At the nearest zoom level, individual member pins should be displaying.

You can also run the import tests to verify that data is indeed importing.

Screenshots (if appropriate):

Types of changes

  • New feature (non-breaking change which adds functionality)

Copy link

linear bot commented Mar 18, 2024

Copy link

render bot commented Mar 19, 2024

@janbaykara janbaykara force-pushed the feature/meep-206-level-25-geo-clustering-layers-by-political-geographies branch from 40b825f to 97e463e Compare March 19, 2024 18:55
@janbaykara janbaykara marked this pull request as ready for review March 19, 2024 18:55
hub/models.py Outdated Show resolved Hide resolved
@janbaykara janbaykara changed the title Feature/meep 206 level 25 geo clustering layers by political geographies Clustering member data by political geographies Mar 19, 2024
Copy link
Member

@conatus conatus left a comment

Choose a reason for hiding this comment

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

This looks really solid. I've got some minor comments I think would be good to be fixed, but it seems in a good place.

hub/analytics.py Outdated Show resolved Hide resolved
hub/graphql/types/model_types.py Show resolved Hide resolved
hub/management/commands/import_areas.py Show resolved Hide resolved
hub/models.py Outdated Show resolved Hide resolved
nextjs/src/app/reports/[id]/page.tsx Show resolved Hide resolved
@conatus
Copy link
Member

conatus commented Mar 20, 2024

As a note over at upstream mysociety#506 they are working at pulling in council data.

I feel like this might be complementary to the work done here to bring in councils, but here in a slightly different way due to PostGIS.

@conatus
Copy link
Member

conatus commented Mar 20, 2024

I am presuming here @janbaykara that wards are shuffling between constituencies, but the boundaries of the wards remain the same in the 2019 electoral map?

@janbaykara
Copy link
Member Author

I am guessing so but haven't researched this @conatus.

I've seen ward data 2023, 2022, 2021 etc so I think they may change a lot more frequently than constituencies; plausible they'll change again to align with the 2024 election?

On the other hand, wards are the electoral unit for council elections not for constituency elections, so also plausible and perhaps more likely that they won't change...

@janbaykara janbaykara merged commit 8c51132 into main Mar 21, 2024
2 checks passed
@ev-sc ev-sc deleted the feature/meep-206-level-25-geo-clustering-layers-by-political-geographies branch December 1, 2024 12:26
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.

2 participants