-
Notifications
You must be signed in to change notification settings - Fork 43
Updating the Congressional District Map Using a Geodatabase or Individual State Shape Files
tmpayton edited this page Dec 12, 2023
·
1 revision
Prerequisites: geopandas
pip install geopandas
- Checkout this branch
- Ensure that SOURCE_FILE is set to
districts.shpand replace all instances ofGEOIDwithGEOID20 - In terminal, go to data folder in fec-cms project
cd fec-cms/fec/fec/static/js/data python3 merge_shape_files.py- Go back to root of project
npm run build-jscd fec/-
./manage.py runserver(might need to clear cookies in browser)
Note: I got a scraping ssl error at first, the fix can be found here Scraping: SSL: CERTIFICATE_VERIFY_FAILED
Prerequisites: QGIS software (this may take awhile).
- Download geodatabase from the Census website
- Open QGIS Layer > Add Layer > Add Vector Layer (make sure directory is highlighted)
- Find the layer that says Current_Congressional_DIstricts in the Layer pane
- Right click on layer > Save features as > ESRI shape file
- save in ~/fec-cms/fec/fec/static/js/data/src directory and name it “districts”
- In terminal, go to data folder in fec-cms project
cd fec-cms/fec/fec/static/js/data ./create_districts_topo.sh- Go back to root of project
npm run build-jscd fec/-
./manage.py runserver(might need to clear cookies in browser)
-
brew install gdal(this will take awhile) - Download geodatabase from the Census website
-
ogr2ogr -f "ESRI Shapefile" "{folder to put shp files}" "{name of geodatabase}.gdb"This will generate a folder with shape files. - Move all "current_congressional_districts" files to ~/fec-cms/fec/fec/static/js/data/src. There should be a .prj file, .dbf file, .shx file, and .shp file
- In terminal, go to data folder in fec-cms project
cd fec-cms/fec/fec/static/js/data - Open file create_districts_topo.sh
- ensure that the variable SOURCE_FILE is set to the name of your shape file from step 4.
- ensure that on line 19 & 21
d.properties.GEOIDsays GEOID and not GEOID20
./create_districts_topo.sh- Go back to root of project
npm run build-jscd fec/-
./manage.py runserver(might need to clear cookies in browser)
Note: The GEOID property is different in the national shape files(GEOID) vs the individual state shapefiles (GEOID20). Depending on which method is used this needs to be changed in the ./create_districts_topo.sh script.