import json

us_states = os.path.join('data', 'us-states.json')

geo_json_data = json.load(open(us_states))

"""
Explanation: Illustration of CRS effect
Leaflet is able to handle several CRS (coordinate reference systems). It means that depending on the data you have, you may need to use the one or the other.
Don't worry ; in practice, almost everyone on the web uses EPSG3857 (the default value for folium and Leaflet). But it may be interesting to know the possible values.
Let's create a GeoJSON map, and change it's CRS.
End of explanation
"""


kw = dict(tiles=None, location=[43, -100], zoom_start=3)

m = folium.Map(crs='EPSG3857', **kw)

folium.GeoJson(geo_json_data).add_to(m)

m.save(os.path.join('results', 'CRS_0.html'))

m

"""
Explanation: EPSG3857 ; the standard
Provided that our tiles are computed with this projection, this map has the expected behavior.
End of explanation
"""


m = folium.Map(crs='EPSG4326', **kw)

folium.GeoJson(geo_json_data).add_to(m)

m.save(os.path.join('results', 'CRS_1.html'))

m

"""
Explanation: EPSG4326
This projection is a common CRS among GIS enthusiasts according to Leaflet's documentation. And we see it's quite different.
End of explanation
"""


m = folium.Map(crs='EPSG3395', **kw)

folium.GeoJson(geo_json_data).add_to(m)

m.save(os.path.join('results', 'CRS_2.html'))

m

"""
Explanation: EPSG3395
The elliptical projection is almost equal to EPSG3857 ; though different.
End of explanation
"""


m = folium.Map(crs='Simple', **kw)

folium.GeoJson(geo_json_data).add_to(m)

m.save(os.path.join('results', 'CRS_3.html'))

m

"""
Explanation: Simple
At last, Leaflet also give the possibility to use no projection at all. With this, you get flat charts.
It can be useful if you want to use folium to draw non-geographical data.
End of explanation
"""


