Adding the points to a map

To simply see the points on the map, we can supply a few parameters and call the show property of the CircleViz object:

viz = CircleViz('tract_points.geojson', access_token=token, 
radius = 2, center = (-122, 37.75), zoom = 8)
viz.show()

The previous code will produce the output as follows:

To classify the data, we can set color stops for specific fields, passing class breaks as a list with associated color information:

color_stops = [
[0.0, 'rgb(255,255,204)'], [500.0, 'rgb(255,237,160)'],
[1000.0, 'rgb(252,78,42)'], [2500.0, 'rgb(227,26,28)'],
[5000.0, 'rgb(189,0,38)'],
[max(tract_points['Total Population']),'rgb(128,0,38)']
]
viz.color_property = 'Total Population'
viz.color_function_type = 'interpolate'
viz.color_stops = color_stops
viz.radius = 1
viz.center = (-122, 37.75)
viz.zoom = 8

viz.show()

The output will look like this:

Add some new fields to the tract_points GeoDataFrame and resave it:

tract_points['Percent Male'] = tract_points['Male Population']/tract_points['Total Population']
tract_points['Percent Female'] = tract_points['Female Population']/tract_points['Total Population']
tract_points.to_file("tract_points2.geojson", driver="GeoJSON")
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset