Learning R for mapping with Leaflet.
Seems like a great guide here, but I’m stuck with a Chropleths map.
https://rstudio.github.io/leaflet/choropleths.html
Download the USA geoson file. It’s in my local R directory, the path is correct. Have changed zero. My understanding it’s a solid geoson file for the USA.
Used in the demo.
https://leafletjs.com/examples/choropleth/us-states.js
I can see the file is there, no problems.
file.exists("json/us-states.geojson")
Returns [TRUE]
Yet I get an error. It’s invalid.
Image 1
So I got over to http://geojsonlint.com/. Paste the entire file in, and I get the attached error. It's not a valid geoson file.
Image 2.
So I’m stuck at square 1. My file is there, yet somehow it’s been corrupted, and not able to be read. Not sure how that could happen.
Wondering what I’m doing wrong here. Would love to get to square 2.
thanks :-)
var statesData =
part, and the semicolon at the very end. Get rid of those, and it will be just the JSON object, without the assignment that would be part of a JS script.sf::read_sf
and it worked fine, although it gave me a warning about potentially invalid bounding box. It appears that some of the longitudes extend to-188.90491
to wrap Alaska across the antimeridian.