import berrl as bl # please, if possible, don't abuse this key its not difficult to get your own apikey='your api key' a=bl.make_points('sharks.csv') bl.parselist(a,'sharks.geojson') # simply writes a list of lines to file name location bl.loadparsehtml(['sharks.geojson'],apikey)
total=bl.list2df(total) # getting the unique activities that occured uniques=np.unique(total['Activity']).tolist() # we now have a list with each top geohash in a aggregated table # we can now style each color icon based on each activity being performed during the attack count=0 filenames=[] for unique,color in itertools.izip(uniques,colors): count+=1 filename=str(count)+'.geojson' # generating a dummy file name temp=total[total.Activity==unique] if not len(temp)==0: # if dataframe is empty will not make_points temp['color']=str(color) # setting specific color to object a=bl.make_points(temp,list=True) # making geojson object bl.parselist(a,filename) # writing object to file filenames.append(filename) # writing the squares table and setting color to red squares['color']='red' a=bl.make_blocks(squares,list=True) bl.parselist(a,'squares.geojson') # adding squares to filenames filenames.append('squares.geojson') #loading final html bl.loadparsehtml(filenames,apikey,colorkey='color')
from pipeleaflet import * import pandas as pd import berrl as bl import numpy as np # loading a csv file of traffic fatalities fatalities = pd.read_csv('wv_fatalities.csv') # Adding the COLORKEY field by iterating through categorriclas of # the input field in this case the field represents causes of traffic fatalities # A field called COLORKEY if automatically added behind the scenes # a groupby and a generator is all thatas going on fatalities = bl.unique_groupby(fatalities, 'VAR23C') print fatalities # making geojson of the csv file bl.make_points(fatalities, filename='fatalities.geojson') # parsing / writing out the html to index.html # we now have colorkey fields to style by # colorkey fields are just 6-digit hex rgb strings load(['fatalities.geojson'], colorkey='COLORKEY')
key='pk.eyJ1IjoibXVycGh5MjE0IiwiYSI6ImNpam5kb3puZzAwZ2l0aG01ZW1uMTRjbnoifQ.5Znb4MArp7v3Wwrn6WFE6A' # reading into memory points=pd.read_csv('points_example.csv') line=pd.read_csv('line_example.csv') # geohashing each table points=bl.map_table(points,7,list=True) line=bl.map_table(line,7,list=True) # getting unique geohashs uniquepoints=np.unique(points['GEOHASH']).tolist() uniqueline=np.unique(line['GEOHASH']).tolist() newpoints=[points.columns.values.tolist()] # we know if a unique point is in any unique line its on the route for row in uniquepoints: oldrow=row for row in uniqueline: if row==oldrow: temp=points[points.GEOHASH==oldrow] temp=bl.df2list(temp) newpoints+=temp[1:] # getting all the points within this geohashs # making the new points, line, and blocks along line bl.make_points(newpoints,list=True,filename='points.geojson') bl.make_blocks('squares7.csv',filename='blocks_on_line.geojson') bl.make_line(line,list=True,filename='line.geojson') bl.loadparsehtml(bl.collect(),key)
import berrl as bl # please, if possible, don't abuse this key its not difficult to get your own apikey = 'your api key' a = bl.make_points('sharks.csv') bl.parselist( a, 'sharks.geojson') # simply writes a list of lines to file name location bl.loadparsehtml(['sharks.geojson'], apikey)
import pandas as pd import berrl as bl from pipeleaflet import * data1 = pd.read_csv('polygon_example.csv') data2 = pd.read_csv('points_example.csv') data3 = pd.read_csv('line_example.csv') data4 = pd.read_csv('blocks_example.csv') bl.make_polygon(data1,filename='polygon.geojson') bl.make_points(data2,filename='points.geojson') bl.make_line(data3,filename='line.geojson') dictrow1 = {'color':'#25D2EA','weight':10} dictrow2 = {'color':'#CC33FF','radius':1} dictrow3 = {'color':'#FFE800','weight':20} filenames = ['polygon.geojson','points.geojson','line.geojson'] stylerows = [dictrow1,dictrow2,dictrow3,dictrow4] load(filenames,stylerows=stylerows)