PyPSA / powerplantmatching

Set of tools to combine multiple power plant databases
https://powerplantmatching.readthedocs.io/en/latest/
GNU General Public License v3.0
152 stars 52 forks source link

Adding Open Street Map (OSM) as a source #12

Open danielsjf opened 5 years ago

danielsjf commented 5 years ago

Some non EU countries are harder to find consistent data for. Could OSM be added for these countries as a source? Not all generators have names, but some do have names and capacities.

A quick example for Turkey with the Overpass-turbo API: https://overpass-turbo.eu/#

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“power=plant in Turkey”
*/
[out:json][timeout:110];
// fetch area “Turkey” to search in
{{geocodeArea:Turkey}}->.searchArea;
// gather results
(
  // query part for: “power=plant”
  node["power"="plant"](area.searchArea);
  way["power"="plant"](area.searchArea);
  relation["power"="plant"](area.searchArea);
  node["power"="generator"](area.searchArea);
  way["power"="generator"](area.searchArea);
  relation["power"="generator"](area.searchArea);
);
// print results
out body;
>;
out skel qt;

image

image

FabianHofmann commented 5 years ago

Hey @danielsjf

that is definitely a good idea. Some problems occurred so far as I had a first try:

A python snippet which uses your code (I changed Turkey into Luxembourg as it is smaller)


    import requests
    overpass_url = "http://overpass-api.de/api/interpreter"
    overpass_query = """
    [out:json][timeout:210];
    area["name"="Luxembourg"]->.boundaryarea;
    (
    // query part for: “power=plant”
    node["power"="plant"](area.boundaryarea);
    way["power"="plant"](area.boundaryarea);
    relation["power"="plant"](area.boundaryarea);
    node["power"="generator"](area.boundaryarea);
    way["power"="generator"](area.boundaryarea);
    relation["power"="generator"](area.boundaryarea);
    );
    out body;
    """
    response = requests.get(overpass_url,
                            params={'data': overpass_query})
    data = response.json()
    df = pd.DataFrame(data['elements'])
    df = pd.concat([df.drop(columns='tags'), df.tags.apply(pd.Series)], axis=1)

works well. One could now loop over the countries with this snippet. Perhaps you want to give it a try?

pz-max commented 1 year ago

@FabianHofmann as mentioned, @davide-f worked on his fork on integrating OpenStreetMap data for generators. Compare here Davide's branch new_pypsa_africa with the PyPSA master: https://github.com/PyPSA/powerplantmatching/compare/master...davide-f:powerplantmatching:new_pypsa_africa.

Basically, we retrieve the OSM and store it locally. The EXTERNAL_DATABASE function allows to add locally stored data to the powerplantmatching process. This is helpful if any local data on your PC e.g. 'closed data' or 'open data' should be quickly added without building and API to the database.

I think we could split Davide's fork contribution in two parts: