-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: add script to translate urban and rural shapefiles to USA tamu loadzones #319
base: develop
Are you sure you want to change the base?
Conversation
lower_48_states_abv.remove("AK") | ||
lower_48_states_abv.remove("HI") | ||
|
||
zone2state_abv = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"]
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there supposed to be more after "Creates a matrix that can be used to transform"?
rural_areas["urban"] = False | ||
|
||
return urban_areas.append(rural_areas, ignore_index=True)[ | ||
return pd.concat([urban_areas, rural_areas], verify_integrity=True)[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hadn't seen the verify_integrity
parameter before, that's neat.
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.py
I 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