forked from zoningatlas/web-map
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update .gitignore to accomodate JupyterNotebooks * Create ipynb for .shp files of district geojson * Incorporate senate district .shp and refactor for cleanliness * Calculate polygon areas within shape files * Refactor district ipynb * Update .gitignore to account for excess shape files * Update humans.txt
- Loading branch information
Showing
5 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9ad655a9-5e0d-4905-a07f-42453777469b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"\"\"\"\n", | ||
"Calculates percentage of land within house and senate districts\n", | ||
"\n", | ||
"@file: DistrictStatistics.ipynb\n", | ||
"\"\"\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9bfe5c8c-50fe-48e0-9019-4fc7ee0bada3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import geopandas as gpd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d7a0c367-76c4-492b-a3c7-26fbe79172e5", | ||
"metadata": {}, | ||
"source": [ | ||
"## Format districts to specified shape files" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a5c71b5b-45db-42e8-b67c-bab79a6c6016", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"\"\"\"\n", | ||
"Disclaimer - '.dbf' files has a column name limitation of 10 characters\n", | ||
"As .dbf files only contain the attribute data of the .shp files,\n", | ||
"in addition to concerns on renaming every column,\n", | ||
"this program voluntarily ignores the proceeding column warning.\n", | ||
"\"\"\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3951edc6-367a-48e9-a0dc-1c3e315389be", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Calculate shape files fore house districts\n", | ||
"\n", | ||
"gdf = gpd.read_file('../data/house-districts.min.geojson')\n", | ||
"gdf.to_file('./district-shapes/house-districts.shp', driver='ESRI Shapefile')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "cacd5911-6077-4ead-a07c-02bd25467c4b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Calculate shape files fore senate districts\n", | ||
"\n", | ||
"gdf = gpd.read_file('../data/senate-districts.min.geojson')\n", | ||
"gdf.to_file('./district-shapes/senate-districts.shp', driver='ESRI Shapefile')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b5da6862-01ab-4afa-a502-06b4da7be3ed", | ||
"metadata": {}, | ||
"source": [ | ||
"## Define polygon areas within a shapefile" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e21746f7-b630-47e8-ac6d-0402dbfcd41f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Calculate area for house district\n", | ||
"\n", | ||
"gdf_house = gpd.read_file('./district-shapes/house-districts.shp')\n", | ||
"\n", | ||
"# CRS needed for better area calculation\n", | ||
"gdf_house = gdf_house.to_crs(epsg=3857)\n", | ||
"gdf_house['house_area'] = gdf_house['geometry'].area" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b8d6156a-3476-4f0a-a57d-10a8f1207e9a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Calculate area for senate district\n", | ||
"\n", | ||
"gdf_senate = gpd.read_file('./district-shapes/senate-districts.shp')\n", | ||
"gdf_senate = gdf_senate.to_crs(epsg=3857)\n", | ||
"gdf_senate['senate_area'] = gdf_senate['geometry'].area" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Binary file not shown.
This file contains 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