Membership Map Issue#10
Issue Link 🔗:
Issue: #10
Type of Change
- [ ] Bug fix 🐞
- [X] New feature/page
- [ ] Documentation update
- [ ] Other
Description 📋
-
What: Provide an overview of the issue this PR addresses. Explain the context and background information.
-
Why: Describe why the changes are being made. Highlight key updates, new features, or bug fixes.
-
How: Explain how these changes will affect the project or end-users.
Checklist ✅
- [ ] Followed the Code of Conduct and Contribution Guide
- [ ] Ran
pre-commit run --all - [ ] All tests pass locally
- [ ] Added tests (if applicable)
- [ ] Documentation updated (if applicable)
Additional Notes & Screenshots
Source data json file from: https://github.com/bsrweb/geo-json-countries-mapbox/blob/master/countries/all-countries.json
See below starter code to create a membership map.
import json
with open("iso.json", "r") as file: data = json.load(file)
def test_json(): for feature in data["features"]: print(f"Type: {feature['type']}, A3: {feature['properties']['A3']}") print(f"Geometry Type: {feature['geometry']['type']}") print(f"Coordinates: {feature['geometry']['coordinates']}") print("-" * 40)
ISO = { "US":"USA", "UNITED KINGDOM":"GBR", "CANADA":"CAN", "KENYA":"KEN", "NIGERIA":"NGA",
}
def test_bpd_countries(): for b in bpd_countries: print(b)
def coord_finder(code): for coord in data["features"]: if coord["properties"]["A3"] == code: return coord["geometry"]["coordinates"]
bpd_countries = [ { "country_name":"US", "country_code": ISO["US"], "events":["PyTexas","PyOhio"], "members":8, "coord": coord_finder(ISO["US"])},
{ "country_name":"UK",
"country_code": ISO["UNITED KINGDOM"],
"events":["PyLondon","PyBrisbane"],
" members":8,
"coord": coord_finder(ISO["UNITED KINGDOM"])},
{ "country_name":"Canada",
"country_code": ISO["CANADA"],
"events":["PyVancouver","PyBritishColumbia"],
"members":2,
"coord": coord_finder(ISO["CANADA"])},
{ "country_name":"KENYA",
"country_code": ISO["KENYA"],
"events":["PyNairobi"],
"members":6,
"coord": coord_finder(ISO["KENYA"])},
{ "country_name":"NIGERIA",
"country_code": ISO["NIGERIA"],
"events":["Lagos"],
"members":9,
"coord": coord_finder(ISO["NIGERIA"])},
]
test_json() test_bpd_countries()