Exemplo n.º 1
0
def zoning_dict2map(zones,translated_geoms):
    threshold = .00000005  #choose this by trial and error, or inspecting VWSimplifier.ordered_thresholds of an example polygon
    mymap = Map()
    n = len(zoning.keys())
    n = 3 if n<3 else n
    colors = get_map('Dark2','Qualitative',n).hex_colors.__iter__()
    print("building datasets")
    for appname,datasets in zoning.items():
       appcolor = colors.next()
       thisapp = App(sanitize_id(appname),title=appname)
       mymap.apps.append(thisapp)
       num_datasets = len(datasets)+3 #don't go to gradient.end
       datacoloriter = gradient(num_datasets,
                                 start=hex2rgb(appcolor))
       for dataname,zone_fields in sorted(datasets.items()):
          color = datacoloriter.next()
          dset = DataSet(sanitize_id(dataname),title=dataname,
                   latlon=False,key_color=color,precision=9)
          thisapp.datasets.append(dset)
          for i,z in enumerate(zones):
            for target in zone_fields:
              if target in z:
               geom = translated_geoms[i]
               if geom.geom_name == 'POLYGON':
                 dset.add_polygon([geom.tuple],
                           threshold=threshold,fillColor=color,
                           strokeColor=color)
               elif geom.geom_name == 'MULTIPOLYGON':
                 dset.add_polygon(geom.tuple,
                           threshold=threshold,fillColor=color,
                           strokeColor=color)
    print("building map")
    mymap.build_page(zoom=13)
Exemplo n.º 2
0
#
# An example of building data from an app
#
#
###

WhereWeMeet_data = {
    'id': 'WhereWeMeet',  #used for tag names
    'title': 'Average Drive Time',  #used for display
}

app_id = 'wherewemeet'
contour_app = App(app_id, title="Composite Drive Time")

for i, d in enumerate(App3.data()):
    this = DataSet('%s%s' % (app_id, i), title=d['keyValue'])
    this.add_polygon(d['polygon'],
                     fillColor=d['fillColor'],
                     strokeColor=d['strokeColor'],
                     fillOpacity=d['fillOpacity'])
    this.key_color = d['fillColor']
    print d['fillColor']
    contour_app.datasets.append(this)

if __name__ == '__main__':
    Austin = [30.320000, -97.770000]
    mymap = map_from_csvs(data_dir='./example_data')
    mymap.build_page(center=Austin, zoom=5, outfile='from_csv_example.html')
    mymap.apps.append(contour_app)
    mymap.build_page(center=Austin, zoom=9, outfile='two_apps.html')
Exemplo n.º 3
0
    #translate all geoms to (lon,lat)
    _world_spatref = SpatialReference('WGS84')
    coord_transform = CoordTransform(geoms[0].srs,_world_spatref)
    for geom in geoms:
      geom.transform(coord_transform)

    print("building datasets")
    bigmap = Map()
    appcolor = -1 #used to generate a unique color for each app
    for app_name in zone_dict.keys():
      appcolor += 1
      this_app = App(app_name,title=app_name)
      bigmap.apps.append(this_app)
      n = len(zone_dict[app_name])+1
      colors = gradient(n,start=int2rgb(appcolor))
      for datasetname, indices in sorted(zone_dict[app_name].items(),key=lambda item: len(item[1]),reverse=True):
        color = colors.next()
        #the x is to uniqueify the dataset id from the app
        sane_name = '%sx'%'x'.join(datasetname.split('-'))
        dset = DataSet(sane_name,key_color=color,title=datasetname,latlon=False,precision=8)
        this_app.datasets.append(dset)
        for i in indices:
          geom = geoms[i]
          if geom.geom_name == 'POLYGON':
            dset.add_polygon([geom.tuple],threshold=.005,fillColor=color)
          elif geom.geom_name == 'MULTIPOLYGON':
            dset.add_polygon(geom.tuple,threshold=.005,fillColor=color)
    print("building map")
    bigmap.build_page(zoom=11)
Exemplo n.º 4
0
# An example of building data from an app
#
#
###

WhereWeMeet_data = {
    'id' : 'WhereWeMeet',       #used for tag names
      'title': 'Average Drive Time',   #used for display

      }

app_id = 'wherewemeet'
contour_app = App(app_id,title="Composite Drive Time")

for i,d in enumerate(App3.data()):
    this = DataSet('%s%s'%(app_id,i),title = d['keyValue'])
    this.add_polygon(d['polygon'],fillColor=d['fillColor'],strokeColor=d['strokeColor'],fillOpacity=d['fillOpacity'])
    this.key_color = d['fillColor']
    print d['fillColor']
    contour_app.datasets.append(this)
    
    


if __name__ == '__main__':
  Austin = [30.320000, -97.770000]
  mymap = map_from_csvs(data_dir = './example_data')
  mymap.build_page(center=Austin,zoom=5,outfile='from_csv_example.html')
  mymap.apps.append(contour_app)
  mymap.build_page(center=Austin,zoom=9,outfile='two_apps.html')