Skip to content

Commit

Permalink
Merge pull request #203 from chihacknight/power-plant-map-imgs
Browse files Browse the repository at this point in the history
Add Satellite Imagery of All Fossil Power Plants
  • Loading branch information
vkoves authored Aug 4, 2023
2 parents fa1c06c + cb83086 commit 70cfafe
Show file tree
Hide file tree
Showing 6,254 changed files with 75 additions and 5 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "none"
}
34 changes: 34 additions & 0 deletions data/scripts/fetch_map_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import requests
import json
from slugify import slugify

# Define the data structure
data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")

with open(os.path.join(data_dir, "final/power_plants/power_plants.json")) as f:
json_str = f.read()
data = json.loads(json_str)

for state in data:
for plant in state["power_plants"]:
fossil_fuel_category = plant["fossil_fuel_category"]
if fossil_fuel_category in ["GAS", "COAL", "OIL"]:
plant_name = plant["plant_name"]
lat = plant["Latitude"]
lng = plant["Longitude"]
image_url = (
f"https://maps.googleapis.com/maps/api/staticmap?"
f"markers=size:mid|{lat},{lng}"
"&scale=2"
"&zoom=16"
"&size=400x400"
"&maptype=satellite"
"&key=AIzaSyChJYejLT7Vxh_UZhJkccsy0xqZTHX8fzU"
)

print("saving image", plant_name)
filename = f"power-plant-maps/{state['state']}-{slugify(plant_name)}.png"
os.makedirs(os.path.dirname(filename), exist_ok=True)
with open(filename, "wb") as f:
f.write(requests.get(image_url).content)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/scripts/new_power_plant_maps/alaska-tok.jpg
Loading

0 comments on commit 70cfafe

Please sign in to comment.