Using R to fetch and parse geojson file from api

421 Views Asked by At

I need to fetch a GeoJSON dataset from an ESRI open data API and then parse the resulting data. Has anyone used R to fetch geoJSON data from an API and turn it into a data frame for analysis?

Here's an example of the data I'm looking to fetch:

List of active businesses in LA: http://geohub.lacity.org/datasets/5caa1112258942c68fc4cce33fc13874_0

API endpoint: http://geohub.lacity.org/datasets/5caa1112258942c68fc4cce33fc13874_0.geojson

Thank!

1

There are 1 best solutions below

0
On

If the file is a well-formed json then this should do it:

library(jsonlite)
document <- jsonlite::fromJSON(txt ="http://geohub.lacity.org/datasets/5caa1112258942c68fc4cce33fc13874_0.geojson")