Exporting GeoJson data from ESRI Arcgis

Many government agencies have published datasets of internal information for use by the public. For example, there has been significant interest in datasets by local law enforcement. Mapping data is often rendered through the public ESRI ArcGIS website, such as this example which shows Harrisburg Police Districts | GIS Datahub (arcgis.com):

It seems that the owner of the data can elect whether to allow the files to be downloadable or not, independent of the license the owner applies to the source. In many cases, files are publicly viewable, but not downloadable in an obvious fashion, although if you do a “view source” on the page, you can copy out the SVGs and render on it’s own, lacking the lat/long data:

For these files, arcgis has a parallel service, which lets you “query” the data. In the general case, these files could be quite large, so I think the service is not generally intended to be the way to download the source. However, for a lot of municipal data, it is really quite small, and the query API is good.

Query (Feature Service)—ArcGIS REST APIs | ArcGIS Developers

For instance, in the Harrisburg police data set, this is the API:

Query: Harrisburg Police Districts (ID: 0) (arcgis.com)

If you change “where” to “1=1”, it pulls all data, and if you change format to “geojson”, you then get a usable format: