edgi-govdata-archiving / ECHO-Cross-Program

Jupyter Notebooks for ECHO that use data from multiple EPA programs
https://colab.research.google.com/github/edgi-govdata-archiving/ECHO-Cross-Program/blob/master/ECHO-Cross-Programs.ipynb
GNU General Public License v3.0
8 stars 5 forks source link

404 handling geojson for states with only one congressional district #137

Closed Frijol closed 2 years ago

Frijol commented 2 years ago

Notebook: https://colab.research.google.com/github/edgi-govdata-archiving/ECHO-Cross-Program/blob/main/ECHO-Cross-Programs.ipynb#scrollTo=EHQ-mlKUaRLQ

To reproduce: Congressional District > DE > 1 > run through cell 8

Error:

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-13-10c1b930e927> in <module>()
     13             for region in regions_selected:
     14                 url = "https://raw.githubusercontent.com/unitedstates/districts/gh-pages/cds/2016/{}-{}/shape.geojson".format( state, str(region))
---> 15                 map_data = gpd.read_file(url)
     16                 map_data_list.append( map_data )
     17             map_data = gpd.GeoDataFrame( pd.concat( map_data_list, ignore_index=True) )

6 frames
/usr/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    647 class HTTPDefaultErrorHandler(BaseHandler):
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 
    651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found
Frijol commented 2 years ago

Found the issue. For states with only 1 district (e.g. DE, AK, etc.), our source (https://github.com/unitedstates/districts/tree/gh-pages/cds/2016) labels the district "0" rather than "1". To close this issue, set up handling for these special cases.