iandees / election-geodata

Precinct shapes (and vote results) for US elections past, present, and future
0 stars 0 forks source link

Montana: Ravalli County #41

Open iandees opened 6 years ago

iandees commented 6 years ago

Need to extract to GeoJSON.

danbjoseph commented 6 years ago

esri2geojson http://rcmtgis.maps.arcgis.com/apps/View/index.html?appid=811e0da0d5a64505a7ac25f51fd99944 ravalli-county.geojson

didn't work and returns:

2018-09-26 13:14:56,128 - cli.esridump - ERROR - Could not parse response from http://rcmtgis.maps.arcgis.com/apps/View/index.html?appid=811e0da0d5a64505a7ac25f51fd99944&f=json as JSON:

<!DOCTYPE html>
<html>

....

</html>
Traceback (most recent call last):
  File "/Users/danbjoseph/Documents/esridump/bin/esri2geojson", line 11, in <module>
    sys.exit(main())
  File "/Users/danbjoseph/Documents/esridump/lib/python2.7/site-packages/esridump/cli.py", line 108, in main
    feature = next(feature_iter)
  File "/Users/danbjoseph/Documents/esridump/lib/python2.7/site-packages/esridump/dumper.py", line 293, in __iter__
    metadata = self.get_metadata()
  File "/Users/danbjoseph/Documents/esridump/lib/python2.7/site-packages/esridump/dumper.py", line 138, in get_metadata
    metadata_json = self._handle_esri_errors(response, "Could not retrieve layer metadata")
  File "/Users/danbjoseph/Documents/esridump/lib/python2.7/site-packages/esridump/dumper.py", line 89, in _handle_esri_errors
    data = response.json()
  File "/Users/danbjoseph/Documents/esridump/lib/python2.7/site-packages/requests/models.py", line 896, in json
    return complexjson.loads(self.text, **kwargs)
  File "/Users/danbjoseph/Documents/esridump/lib/python2.7/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/Users/danbjoseph/Documents/esridump/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/Users/danbjoseph/Documents/esridump/lib/python2.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

opened Chrome dev tools and refreshed the page with the Network tab open. dug through and found:

https://services2.arcgis.com/5nOJDDRnnsbCKWWP/arcgis/rest/services/Voting_Precincts/FeatureServer/0/query?f=pbf&where=1%3D1&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=*&outSR=102100&resultOffset=0&resultRecordCount=4000&resultType=tile&quantizationParameters=%7B%22mode%22%3A%22view%22%2C%22originPosition%22%3A%22upperLeft%22%2C%22tolerance%22%3A1.0583354500042301%2C%22extent%22%3A%7B%22xmin%22%3A-12764749.609836664%2C%22ymin%22%3A5692521.652130197%2C%22xmax%22%3A-12632873.693011217%2C%22ymax%22%3A5891711.751228908%2C%22spatialReference%22%3A%7B%22wkid%22%3A102100%2C%22latestWkid%22%3A3857%7D%7D%7D

which i cut down and ran: esri2geojson https://services2.arcgis.com/5nOJDDRnnsbCKWWP/arcgis/rest/services/Voting_Precincts/FeatureServer/0 ravalli-county.geojson

ravalli-county.geojson.txt