A lot of geospatial data (GIS) is stored on ArcGIS MapServers, which is part of the Esri “stack” of products that municipalities use to manage and publish GIS data. And a lot of people want that data. If you have ArcGIS software on your Windows computer, then it can be pretty easy to plug in the map server URL and manipulate and extract the data.
For the rest of us who don’t have an extremely expensive license to that software, you can use a “command line” tool (written in Python) on any computer to download any layer of GIS data hosted on the ArcGIS MapServer and automatically convert it to GeoJSON.
You’ll need to install the Python package
pyesridump, from the OpenAddresses GitHub repository, created by Ian Dees and other contributors.
pyesridump is easy if you have
pip installed, using the command
pip install esridump.
The next thing you’ll need is the URL to a layer in a MapServer, and these are not easy to find.
Finding data to download
I can guarantee the county where you live has one. Before you continue, check to see if your county (or other jurisdiction) has the “open data portal” add-on to their ArcGIS stack.
Here are links to the open data portals enabled by Esri for Lake County, Illinois, and Broomfield County, Colorado). This is much easier to browse and find data to download (in shapefile and other formats) and you can skip this tutorial.
I don’t have a good recommendation to find the MapServer URL, though. A reader suggested looking for MapServers for jurisdictions around the world by looking through Esri’s portal of open data called ArcGIS Hub. Once you locate a dataset you want, you can find the MapServer URL under About>Data Source on the right side of the page.
I normally find them by looking at the HTML source code of a MapServer I already know about.
For this example I’ll use one of the GIS layers in the Cook County, Illinois, election service MapServer – here’s the layer for the Cook County commissioners districts.
Fetch the data
Once you have the URL the command is simple:
esri2geojson http://cookviewer1.cookcountyil.gov/ArcGIS/rest/services/cookElectnSrvc/MapServer/11 cookcounty_commissioners.geojson
- The first term,
esri2geojsontells your computer which program to load.
- The second term is the URL of the MapServer URL.
- The third term is the filename and location where you want to store the file. I prefer running the command “inside” the folder where I want the file to be stored. You can also specify a full path of the file. On a Mac this would look like
After you enter the command into your computer’s terminal, press enter.
esri2geojson will report back once, after it finds and understands the MapServer URL you gave it. When it’s done, the command will “close” and your computer’s terminal will wait for the next command.
Do you have questions, or need some help? Leave a comment below.