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

Error due to WPC areas in May 2022 boundary line data #385

Closed
torotil opened this issue May 10, 2022 · 6 comments · Fixed by #386
Closed

Error due to WPC areas in May 2022 boundary line data #385

torotil opened this issue May 10, 2022 · 6 comments · Fixed by #386

Comments

@torotil
Copy link
Contributor

torotil commented May 10, 2022

When doing a fresh install with the May 2022 boundary line data I get an error during the import:

  New area: WPC W09000029 41405 Cardiff West P Const
Traceback (most recent call last):
  File "/home/roman/code/mapit-build/mapit/mapit_gb/management/commands/mapit_UK_import_boundary_line.py", line 114, in handle_label
    m = Area.objects.get(codes__type=code_version, codes__code=ons_code)
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
mapit.models.Area.DoesNotExist: Area matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/roman/code/mapit-build/mapit/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 571, in handle
    label_output = self.handle_label(label, **options)
  File "/home/roman/code/mapit-build/mapit/mapit_gb/management/commands/mapit_UK_import_boundary_line.py", line 129, in handle_label
    type=Type.objects.get(code=area_code),
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/roman/code/mapit-build/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
mapit.models.Type.DoesNotExist: Type matching query does not exist.

It seems there is no area type for WPC.

@torotil torotil changed the title WPC Error due to WPC areas in May 2022 boundary line data May 10, 2022
@torotil
Copy link
Contributor Author

torotil commented May 10, 2022

Seems like in the new shape files the area_codes for Wales have changed. I’ve added

            if area_code.startswith('WP'):
                area_code = 'WA' + area_code[2:]

to mapit_gb/management/commands/mapit_UK_import_boundary_line.py:71 and that fixed it for me.

@dracos
Copy link
Member

dracos commented May 10, 2022

We imported 2022-05 Boundary-Line without receiving this error, so I am confused! And hoping I haven't broken something :-/ Thanks for letting us know. Ah, I guess as we had existing data with the same ONS GSS code, it matched on that and so did not have to try to create a new area.

@dracos
Copy link
Member

dracos commented May 10, 2022

So if they have renamed WAC and WAE to WPC and WPE (obliquely referenced in the release notes as a Welsh Parliament name change, but not in a way that meant I realised), question is whether we should maintain them as WAC/WAE (as your change would do), or add them as new Types. Seems silly to break WAC/WAE for no reason (it's not even as if any boundaries have changed), so your idea sounds good to me unless I've missed something. (We'd already renamed the descriptions of WAC/WAE to use Senedd in our MapIt some time ago.)

@dracos
Copy link
Member

dracos commented May 11, 2022

Though should we have done the same with EUR->ER for the English regions, hmm. Guess too late there.

Also if you don't know, North Ayrshire and Arran WMC is missing from the new Boundary-Line.

@torotil
Copy link
Contributor Author

torotil commented May 11, 2022

@dracos Thanks for confirming that that’s indeed a good fix … and also for the info about the WMCs. I guess you just had to raise the generation to get them from an earlier import, right?

Seems I also need to wrap my brain around adding the new councils (Cumbria, Somerset, …). As the new areas seem to be supersets of the existing ones this should be easily scriptable.

@dracos
Copy link
Member

dracos commented May 11, 2022

Yes, that's how I noticed, when there was one WMC left in the old generation :) Yeah, if you need them sooner, that's how you'd have to do it, I think (might eventually get around to doing #7 someday!). They'll then be in the May 2023 Boundary-Line, it sounds like.

#386 - thanks for the suggestion, I decided probably better to be explicit about what's being replaced, just in case.

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 a pull request may close this issue.

2 participants