pypsa-meets-earth / earth-osm

Export infrastructure data from OpenStreetMap using Python
https://pypsa-meets-earth.github.io/earth-osm/
MIT License
23 stars 12 forks source link

Some regions (e.g. Panama) do have the id but not the country code and cannot be accessed with the country code #33

Closed davide-f closed 1 year ago

davide-f commented 1 year ago

When running earth_osm view regions, "panama" is available in central-america with flag "panama" but NaN country code. When using earth_osm using PA, it does not work. When country_code is NaN, it may be filled using country_converter, that would help a lot. I fear this may occur for other countries as well.

        {
            "type": "Feature",
            "properties": { 
                "id" : "panama",
                "parent" : "central-america",
                "name" : "Panama",
                "urls" : {
                    "pbf" : "https://download.geofabrik.de/central-america/panama-latest.osm.pbf",
                    "bz2" : "https://download.geofabrik.de/central-america/panama-latest.osm.bz2",
                    "shp" : "https://download.geofabrik.de/central-america/panama-latest-free.shp.zip",
                    "pbf-internal" : "https://osm-internal.download.geofabrik.de/central-america/panama-latest-internal.osm.pbf",
                    "history" : "https://osm-internal.download.geofabrik.de/central-america/panama-internal.osh.pbf",
                    "taginfo" : "https://taginfo.geofabrik.de/central-america/panama/",
                    "updates" : "https://download.geofabrik.de/central-america/panama-updates"
                }
            }
        },
davide-f commented 1 year ago

I investigated a bit the issue and a potential fix is in https://github.com/davide-f/earth-osm/tree/parse_nan_country_codes . However, my feeling is that this postprocessing makes things more complicated.

I think this is a feature not desirable for the main repo: the conversion may convert too much.

mnm-matin commented 1 year ago

I believe you can use the name, country code or a mixture of them.

I have confirmed the following to be working: earth_osm extract power --regions panama

davide-f commented 1 year ago

Indeed, I've implemented that. At the beginning it sounded weird but it is the most suitable approach. Since you agree, I close this issue