feat: add script to translate urban and rural shapefiles to USA tamu loadzones#319
Open
feat: add script to translate urban and rural shapefiles to USA tamu loadzones#319
Conversation
added 10 commits
October 23, 2022 16:43
jenhagg
reviewed
Nov 16, 2022
| lower_48_states_abv.remove("AK") | ||
| lower_48_states_abv.remove("HI") | ||
|
|
||
| zone2state_abv = { |
Collaborator
There was a problem hiding this comment.
I think we could reuse the same lookup from powersimdata, e.g.
from powersimdata.network.model import ModelImmutables
mi = ModelImmutables("usa_tamu")
zone2state_abv = mi.zones["loadzone2abv"]
jenhagg
reviewed
Nov 16, 2022
|
|
||
| def translate_urban_rural_to_usa_tamu(): | ||
| """Downloads US state borders as well as census data for urban and rural | ||
| areas in the US. Creates a matrix that can be used to transform |
Collaborator
There was a problem hiding this comment.
Was there supposed to be more after "Creates a matrix that can be used to transform"?
jenhagg
reviewed
Nov 16, 2022
| rural_areas["urban"] = False | ||
|
|
||
| return urban_areas.append(rural_areas, ignore_index=True)[ | ||
| return pd.concat([urban_areas, rural_areas], verify_integrity=True)[ |
Collaborator
There was a problem hiding this comment.
Hadn't seen the verify_integrity parameter before, that's neat.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request doc
Purpose
Create a matrix that can be used to transform urban and rural USA data to USA tamu data. Currently this transformation is strictly based on area.
The USA Tamu shapefiles can be found here: https://besciences.blob.core.windows.net/shapefiles/USA/usa-tamu-loadzones-convex-hull/usa-tamu-loadzones-convex-hull.shp
The resulting matrix generated by this script currently lives here: https://www.dropbox.com/s/y2oopigjg0bxrhb/translate-urban-rural-to-usa-tamu.csv
What the code is doing
translate_zone_set()to generate a matrix translation from the urban/rural data to the newly created USA Tamu dataTesting
Unit tests in
test_generate_rural_shapefiles.pyI tested all the code except the
translate_urban_rural_to_usa_tamu()because that function requires lots of downloading / writing / reading files.Where to look
create_usa_tamu_convex_hull_shapefile()has the most important code.Usage Example/Visuals
How the code can be used and/or images of any graphs, tables or other visuals (not always applicable).
Time estimate
20 mins