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

Add Satellite Imagery of All Fossil Power Plants #203

Merged
merged 17 commits into from
Aug 4, 2023
Merged

Conversation

vkoves
Copy link
Collaborator

@vkoves vkoves commented May 3, 2023

Overview

Adds satellite images to all power plants do you can see how large a plant is and understand it's environment.

Closes #xxx

Demo

Optional. Screenshots, curl examples, etc.

Notes

Optional. Ancillary topics, caveats, alternative strategies that didn't work out, anything else.

Testing Instructions

  • How to test this PR
  • Prefer bulleted description
  • Start after checking out this branch
  • Include any setup required, such as bundling scripts, restarting services, etc.
  • Include test case, and expected output

@netlify
Copy link

netlify bot commented May 3, 2023

Deploy Preview for decarb-my-state ready!

Name Link
🔨 Latest commit cb83086
🔍 Latest deploy log https://app.netlify.com/sites/decarb-my-state/deploys/64b759d2b9c00a000837974f
😎 Deploy Preview https://deploy-preview-203--decarb-my-state.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@vkoves
Copy link
Collaborator Author

vkoves commented May 3, 2023

Demo with my API key:

Screenshot from 2023-05-02 21-18-42

@vkoves
Copy link
Collaborator Author

vkoves commented May 3, 2023

@derekeder - we discussed you making a python script so we can now have power plant pages at say /power-plant-maps/{state-slug}-{plant-slug}.png or something like that. We don't know that plant names are unique so I think keeping the plant slug in there would be helpful.

@JoseMRodriguezO JoseMRodriguezO marked this pull request as ready for review May 11, 2023 18:24
@derekeder
Copy link
Member

@JoseMRodriguezO looks like we're missing your script and the images. Looks like you reverted a commit that had the script in this commit 9c11664. Can you add it back, as well as the 3,500 images?

@JoseMRodriguezO
Copy link
Collaborator

JoseMRodriguezO commented May 16, 2023

commit updated

@JoseMRodriguezO JoseMRodriguezO changed the title Power plant map imgs Power plant map imgs from google api May 16, 2023
@JoseMRodriguezO
Copy link
Collaborator

JoseMRodriguezO commented May 16, 2023

Overview

This pull request adds functionality to fetch power plant data from a JSON file and save map images for each power plant using the Google Static Maps API.

Closes #203

Demo

image

Notes

Added code to read power plant data from a JSON file.

  • Iterated through the power plants in each state and saved map images for each power plant.
  • Handled directory creation for saving image files.
  • Updated the code to use the json.load() function to directly load the JSON file.
  • Added error handling for potential exceptions during file operations and API requests.
  • Refactored the code into separate functions for better organization and reusability.

Testing Instructions

Ensure the necessary dependencies, such as requests and slugify, are installed.

  • Checkout this branch and run the code.
  • Verify that map images are saved for each power plant in the specified directory.
  • Perform thorough testing, including different scenarios and error conditions, to ensure the code functions as expected.

@derekeder
Copy link
Member

@JoseMRodriguezO cool - looks like the images are here! nice!

@vkoves the images are in the data folder. do you want to update this PR and move them to the static directory and link to them on the power plant detail page?

1 similar comment
@derekeder
Copy link
Member

@JoseMRodriguezO cool - looks like the images are here! nice!

@vkoves the images are in the data folder. do you want to update this PR and move them to the static directory and link to them on the power plant detail page?

@vkoves
Copy link
Collaborator Author

vkoves commented Jun 6, 2023

Want to note that this is on my radar and I know I need to get back to this 😆

@vkoves
Copy link
Collaborator Author

vkoves commented Jun 18, 2023

@derekeder and @JoseMRodriguezO - I've integrated the power plant imagery onto the power plant details page, but there's a few things I noticed. First, here's what I have right now:

Screenshot from 2023-06-18 14-30-39

So what I noticed:

  1. We have images for power plants we don't show - maybe we pulled in all power plants and not just gas, coal, and oil? You can technically access these pages though, like ABC Coke in Alabama which must have a data entry issue:

Screenshot from 2023-06-18 14-32-32

  1. The images are huge, totallying 1.5 GB. We should move to a modern format like .webp or even just a more compressed .jpg, because this amount of files will make the repo harder to use but also risks eating up our bandwidth.

@JoseMRodriguezO
Copy link
Collaborator

ok, I will work on it

@vkoves
Copy link
Collaborator Author

vkoves commented Jun 18, 2023

@JoseMRodriguezO - we can talk about it on Tuesday, I think we need to use a tool like ImageMagick to locally compress all the images, but not sure about reducing which power plants we have. If you do want to take a crack at it, this is what I found:

https://unix.stackexchange.com/questions/516435/imagemagick-convert-compress-all-files-in-the-directory

My internal target is < 200 KB per image, but if we could get 100 KB that'd be great. https://squoosh.app/ seems to be able to do that without it looking terrible

@JoseMRodriguezO
Copy link
Collaborator

Hi, Viktor I just finished with imageMagic. I just resize the images to low 200kb at 600x600 I just need to commit now, also separated the plants by category as requested.
I just didnt update my commit before pushing. please verify and let me know.
Thank you,

@vkoves
Copy link
Collaborator Author

vkoves commented Jun 24, 2023

@JoseMRodriguezO - can you post a before after image with one of your images before and after compression? What does the total directory size come out to?

@JoseMRodriguezO
Copy link
Collaborator

Update branch

  • Limit the images for plants (oil, coal, gas)
  • Reduce the size of the images from 800x800
    alabama-barry
  • Current size 600x600
    alabama-barry
  • Initial total size was 1.5gb, Current size 457kb.

@vkoves
Copy link
Collaborator Author

vkoves commented Jun 28, 2023

@JoseMRodriguezO - that sounds awesome! Can you push up the new images?

@vkoves
Copy link
Collaborator Author

vkoves commented Jul 17, 2023

Sorry I've dropped the ball on this, I need to get the styling fixed up and then get someone to review this! It's on my list 😆

@vkoves vkoves changed the title Power plant map imgs from google api Add Satellite Imagery of All Fossil Power Plants Jul 19, 2023
@vkoves
Copy link
Collaborator Author

vkoves commented Aug 2, 2023

@derekeder - this is still waiting on you, it's ready for review

Copy link
Member

@derekeder derekeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it - lets bring it in!

@vkoves vkoves merged commit 70cfafe into main Aug 4, 2023
5 checks passed
@vkoves vkoves deleted the power-plant-map-imgs branch August 4, 2023 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants