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

Namibia ['NA'] not accepted as string in save_osm_data #59

Open
LRydin opened this issue Jan 25, 2025 · 1 comment
Open

Namibia ['NA'] not accepted as string in save_osm_data #59

LRydin opened this issue Jan 25, 2025 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@LRydin
Copy link

LRydin commented Jan 25, 2025

Describe the bug
Rather straightforward. ['NA'] not accepted as string. save_osm_data gets nowhere

To Reproduce

from earth-osm import eo
eo.save_osm_data(['NA'], 'power', ['substation'])

results in an error

ERROR:eo.gfk:NA not found. Check eo.view_regions() or run 'earth_osm view regions'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/earth_osm/eo.py", line 160, in save_osm_data
    region_tuple_list = [get_region_tuple(r) for r in region_list]
  File "/home/ubuntu/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/earth_osm/eo.py", line 160, in <listcomp>
    region_tuple_list = [get_region_tuple(r) for r in region_list]
  File "/home/ubuntu/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/earth_osm/gfk_data.py", line 172, in get_region_tuple
    id = get_id_by_str(region_str)
  File "/home/ubuntu/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/earth_osm/gfk_data.py", line 161, in get_id_by_str
    raise KeyError(f"{region_str} not found. Check eo.view_regions() or run 'earth_osm view regions'")
KeyError: "NA not found. Check eo.view_regions() or run 'earth_osm view regions'"

Note that

from earth-osm import eo
eo.save_osm_data(['namibia'], 'power', ['substation'])

works.

Expected behavior
It would be expected that 'NA' works as all other ISO codes.

Desktop (please complete the following information):

  • OS: Linux, ubuntu 24.04, installed via pypsa-earth
  • Version '2.3.post1'

Idea
Is 'NA' being drop by mistake as "Non-Applicable", much alike a Non-a-Number, in reading the gfk_index.csv somewhere down the pipeline?

@LRydin LRydin added bug Something isn't working help wanted Extra attention is needed labels Jan 25, 2025
@LRydin
Copy link
Author

LRydin commented Jan 25, 2025

Original discussion on PyPSA-meets-Earth discord: https://discord.com/channels/911692131440148490/1331917268862504981

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant