Example #1
0
def draw_choropleth_map(spark):
    df = spark.read.format("csv").option("header", True).option(
        "delimiter", ","
    ).schema(
        "VendorID string, tpep_pickup_datetime timestamp, tpep_dropoff_datetime timestamp, passenger_count long, trip_distance double, pickup_longitude double, pickup_latitude double, dropoff_longitude double, dropoff_latitude double, fare_amount double, tip_amount double, total_amount double, buildingid_pickup long, buildingid_dropoff long, buildingtext_pickup string, buildingtext_dropoff string"
    ).load("file:///tmp/0_5M_nyc_taxi_and_building.csv").cache()
    df.show(20, False)
    df.createOrReplaceTempView("nyc_taxi")
    # df.createOrReplaceGlobalTempView("nyc_taxi")

    res = spark.sql(
        "select buildingtext_dropoff as wkt, passenger_count as w from nyc_taxi"
    )
    res.printSchema()
    res.createOrReplaceTempView("pickup")

    vega_choropleth_map = VegaChoroplethMap(
        1900, 1410, [-73.984092, 40.753893, -73.977588, 40.756342],
        "blue_to_red", [2.5, 5], 1.0)
    vega = vega_choropleth_map.build()
    res = choroplethmap(res, vega)
    save_png(res, '/tmp/choroplethmap.png')

    spark.sql("show tables").show()
    spark.catalog.dropGlobalTempView("nyc_taxi")
Example #2
0
def draw_choropleth_map(spark):
    start_time = time.time()
    df = spark.read.format("csv").option("header", True).option(
        "delimiter", ","
    ).schema(
        "VendorID string, tpep_pickup_datetime timestamp, tpep_dropoff_datetime timestamp, passenger_count long, trip_distance double, pickup_longitude double, pickup_latitude double, dropoff_longitude double, dropoff_latitude double, fare_amount double, tip_amount double, total_amount double, buildingid_pickup long, buildingid_dropoff long, buildingtext_pickup string, buildingtext_dropoff string"
    ).load("file:///tmp/0_5M_nyc_taxi_and_building.csv").cache()
    df.createOrReplaceTempView("nyc_taxi")

    register_funcs(spark)
    res = spark.sql(
        "select ST_GeomFromText(buildingtext_dropoff) as polygon, passenger_count as w from nyc_taxi where (buildingtext_dropoff!='')"
    )

    vega1 = vega_choroplethmap(
        1900,
        1410,
        bounding_box=[-73.994092, 40.753893, -73.977588, 40.759642],
        color_gradient=["#0000FF", "#FF0000"],
        color_bound=[2.5, 5],
        opacity=1.0,
        coordinate_system='EPSG:4326')
    res1 = choroplethmap(vega1, res)
    save_png(res1, '/tmp/choroplethmap1.png')

    spark.sql("show tables").show()
    spark.catalog.dropGlobalTempView("nyc_taxi")
    print("--- %s seconds ---" % (time.time() - start_time))
Example #3
0
def db_query():
    """
    /db/query handler
    """
    log.INSTANCE.info('POST /db/query: {}'.format(request.json))

    if not utils.check_json(request.json, 'id') \
            or not utils.check_json(request.json, 'query') \
            or not utils.check_json(request.json['query'], 'type') \
            or not utils.check_json(request.json['query'], 'sql'):
        return jsonify(status='error', code=-1, message='query format error')

    query_sql = request.json['query']['sql']
    query_type = request.json['query']['type']

    content = {}
    content['sql'] = query_sql
    content['err'] = False

    db_instance = db.CENTER.get(str(request.json['id']), None)
    if db_instance is None:
        return jsonify(status="error",
                       code=-1,
                       message='there is no database whose id equal to ' +
                       str(request.json['id']))

    if query_type == 'sql':
        res = db_instance.run_for_json(query_sql)
        data = []
        for row in res:
            obj = json.loads(row)
            data.append(obj)
        content['result'] = data
    else:
        if not utils.check_json(request.json['query'], 'params'):
            return jsonify(status='error',
                           code=-1,
                           message='query format error')
        query_params = request.json['query']['params']

        res = db_instance.run(query_sql)

        if query_type == 'point':
            vega = vega_pointmap(int(query_params['width']),
                                 int(query_params['height']),
                                 query_params['point']['bounding_box'],
                                 int(query_params['point']['point_size']),
                                 query_params['point']['point_color'],
                                 float(query_params['point']['opacity']),
                                 query_params['point']['coordinate_system'])
            data = pointmap(vega, res)
            content['result'] = data
        elif query_type == 'heat':
            vega = vega_heatmap(int(query_params['width']),
                                int(query_params['height']),
                                query_params['heat']['bounding_box'],
                                float(query_params['heat']['map_zoom_level']),
                                query_params['heat']['coordinate_system'],
                                query_params['heat']['aggregation_type'])
            data = heatmap(vega, res)
            content['result'] = data
        elif query_type == 'choropleth':
            vega = vega_choroplethmap(
                int(query_params['width']), int(query_params['height']),
                query_params['choropleth']['bounding_box'],
                query_params['choropleth']['color_gradient'],
                query_params['choropleth']['color_bound'],
                float(query_params['choropleth']['opacity']),
                query_params['choropleth']['coordinate_system'],
                query_params['choropleth']['aggregation_type'])
            data = choroplethmap(vega, res)
            content['result'] = data
        elif query_type == 'weighted':
            vega = vega_weighted_pointmap(
                int(query_params['width']), int(query_params['height']),
                query_params['weighted']['bounding_box'],
                query_params['weighted']['color_gradient'],
                query_params['weighted']['color_bound'],
                query_params['weighted']['size_bound'],
                float(query_params['weighted']['opacity']),
                query_params['weighted']['coordinate_system'])
            data = weighted_pointmap(vega, res)
            content['result'] = data
        elif query_type == 'icon':
            vega = vega_icon(int(query_params['width']),
                             int(query_params['height']),
                             query_params['icon']['bounding_box'],
                             query_params['icon']['icon_path'],
                             query_params['icon']['coordinate_system'])
            data = icon_viz(vega, res)
            content['result'] = data
        else:
            return jsonify(status="error",
                           code=-1,
                           message='{} not support'.format(query_type))

    return jsonify(status="success", code=200, data=content)
Example #4
0
def db_query():
    """
    /db/query handler
    """
    if not utils.check_json(request.json, 'id') \
            or not utils.check_json(request.json, 'query') \
            or not utils.check_json(request.json['query'], 'type') \
            or not utils.check_json(request.json['query'], 'sql'):
        return jsonify(status='error', code=-1, message='query format error')

    query_sql = request.json['query']['sql']
    query_type = request.json['query']['type']

    content = {}
    content['sql'] = query_sql
    content['err'] = False

    if query_type == 'sql':
        res = spark.Spark.run_for_json(query_sql)
        data = []
        for row in res:
            obj = json.loads(row)
            data.append(obj)
        content['result'] = data
    else:
        if not utils.check_json(request.json['query'], 'params'):
            return jsonify(status='error',
                           code=-1,
                           message='query format error')
        query_params = request.json['query']['params']

        res = spark.Spark.run(query_sql)

        if query_type == 'point':
            vega = vega_pointmap(int(query_params['width']),
                                 int(query_params['height']),
                                 query_params['point']['bounding_box'],
                                 int(query_params['point']['stroke_width']),
                                 query_params['point']['stroke'],
                                 float(query_params['point']['opacity']),
                                 query_params['point']['coordinate'])
            data = pointmap(res, vega)
            content['result'] = data
        elif query_type == 'heat':
            vega = vega_heatmap(int(query_params['width']),
                                int(query_params['height']),
                                float(query_params['heat']['map_scale']),
                                query_params['heat']['bounding_box'],
                                query_params['heat']['coordinate'])
            data = heatmap(res, vega)
            content['result'] = data
        elif query_type == 'choropleth':
            vega = vega_choroplethmap(
                int(query_params['width']), int(query_params['height']),
                query_params['choropleth']['bounding_box'],
                query_params['choropleth']['color_style'],
                query_params['choropleth']['rule'],
                float(query_params['choropleth']['opacity']),
                query_params['choropleth']['coordinate'])
            data = choroplethmap(res, vega)
            content['result'] = data
        else:
            return jsonify(status="error",
                           code=-1,
                           message='{} not support'.format(query_type))
    return jsonify(status="success", code=200, data=content)
Example #5
0
                    coordinate_system="EPSG:4326")
res = heatmap(vega, pickup_df)
save_png(res, "/tmp/arctern_heatmap.png")

# 在指定地理区域(经度范围:-73.991504 至 -73.945155;纬度范围:40.770759 至 40.783434)中随机选取 200 个坐标点,并将 fare_amount 作为颜色权重。
pickup_sql = f"select ST_GeomFromText(buildingtext_pickup) as buildings, fare_amount as color_weight from nyc_taxi where (pickup_longitude between {pos1[0]} and {pos2[0]}) and (pickup_latitude between {pos1[1]} and {pos2[1]}) and (buildingtext_pickup!='') limit {limit_num}"
pickup_df = spark.sql(pickup_sql)
# 根据查询结果绘制轮廓图图层。轮廓的填充颜色根据 color_weight 在 "#115f9a" ~ "#d0f400" 之间变化。
vega = vega_choroplethmap(1024,
                          384,
                          bounding_box=[pos1[0], pos1[1], pos2[0], pos2[1]],
                          color_gradient=["#115f9a", "#d0f400"],
                          color_bound=[2.5, 5],
                          opacity=1.0,
                          coordinate_system="EPSG:4326")
res = choroplethmap(vega, pickup_df)
save_png(res, "/tmp/arctern_choroplethmap.png")

# 在指定地理区域(经度范围:-73.991504 至 -73.945155;纬度范围:40.770759 至 40.783434)中随机选取 25 个坐标点。
pickup_sql = f"select st_point(pickup_longitude, pickup_latitude) from nyc_taxi where (pickup_longitude between {pos1[0]} and {pos2[0]}) and (pickup_latitude between {pos1[1]} and {pos2[1]}) limit 25"
pickup_df = spark.sql(pickup_sql)
# 根据查询结果绘制图标图图层。
# 注意: 请将 /path/to/icon.png 改为 png 文件所在的绝对路径
vega = vega_icon(1024,
                 384,
                 bounding_box=[pos1[0], pos1[1], pos2[0], pos2[1]],
                 icon_path='/path/to/icon.png',
                 coordinate_system="EPSG:4326")
res = icon_viz(vega, pickup_df)
save_png(res, "/tmp/arctern_iconviz.png")
Example #6
0
def run_test_choropleth_map(spark):
    df = spark.read.format("csv").option("header", True).option("delimiter", ",").schema(
        "VendorID string, tpep_pickup_datetime timestamp, tpep_dropoff_datetime timestamp, passenger_count long, "
        "trip_distance double, pickup_longitude double, pickup_latitude double, dropoff_longitude double, "
        "dropoff_latitude double, fare_amount double, tip_amount double, total_amount double, buildingid_pickup long, "
        "buildingid_dropoff long, buildingtext_pickup string, buildingtext_dropoff string").load(
        file_path).cache()
    df.createOrReplaceTempView("nyc_taxi")

    res = spark.sql("select buildingtext_dropoff as wkt, passenger_count as w from nyc_taxi")

    # 1-9 test color_style
    # 1 blue_to_red
    vega_1 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "blue_to_red",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline1 = choroplethmap(res, vega_1)
    choropleth_map1_1 = choroplethmap(res, vega_1)
    choropleth_map1_2 = choroplethmap(res, vega_1)

    baseline_png1 = png_path + "choropleth_map_nyc_1.png"
    save_png(baseline1, baseline_png1)
    save_png(choropleth_map1_1, png_path + "test_choropleth_map_nyc_1-1.png")
    save_png(choropleth_map1_2, png_path + "test_choropleth_map_nyc_1-2.png")

    # 2 green_yellow_red
    vega_2 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "green_yellow_red",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline2 = choroplethmap(res, vega_2)
    choropleth_map2_1 = choroplethmap(res, vega_2)
    choropleth_map2_2 = choroplethmap(res, vega_2)

    baseline_png2 = png_path + "choropleth_map_nyc_2.png"
    save_png(baseline2, baseline_png2)
    save_png(choropleth_map2_1, png_path + "test_choropleth_map_nyc_2-1.png")
    save_png(choropleth_map2_2, png_path + "test_choropleth_map_nyc_2-2.png")

    # 3 blue_white_red
    vega_3 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "blue_white_red",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline3 = choroplethmap(res, vega_3)
    choropleth_map3_1 = choroplethmap(res, vega_3)
    choropleth_map3_2 = choroplethmap(res, vega_3)

    baseline_png3 = png_path + "choropleth_map_nyc_3.png"
    save_png(baseline3, baseline_png3)
    save_png(choropleth_map3_1, png_path + "test_choropleth_map_nyc_3-1.png")
    save_png(choropleth_map3_2, png_path + "test_choropleth_map_nyc_3-2.png")

    # 4 skyblue_to_white
    vega_4 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "skyblue_to_white",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline4 = choroplethmap(res, vega_4)
    choropleth_map4_1 = choroplethmap(res, vega_4)
    choropleth_map4_2 = choroplethmap(res, vega_4)

    baseline_png4 = png_path + "choropleth_map_nyc_4.png"
    save_png(baseline4, baseline_png4)
    save_png(choropleth_map4_1, png_path + "test_choropleth_map_nyc_4-1.png")
    save_png(choropleth_map4_2, png_path + "test_choropleth_map_nyc_4-2.png")

    # 5 purple_to_yellow
    vega_5 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "purple_to_yellow",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline5 = choroplethmap(res, vega_5)
    choropleth_map5_1 = choroplethmap(res, vega_5)
    choropleth_map5_2 = choroplethmap(res, vega_5)

    baseline_png5 = png_path + "choropleth_map_nyc_5.png"
    save_png(baseline5, baseline_png5)
    save_png(choropleth_map5_1, png_path + "test_choropleth_map_nyc_5-1.png")
    save_png(choropleth_map5_2, png_path + "test_choropleth_map_nyc_5-2.png")

    # 6 red_transparency
    vega_6 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "red_transparency",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline6 = choroplethmap(res, vega_6)
    choropleth_map6_1 = choroplethmap(res, vega_6)
    choropleth_map6_2 = choroplethmap(res, vega_6)

    baseline_png6 = png_path + "choropleth_map_nyc_6.png"
    save_png(baseline6, baseline_png6)
    save_png(choropleth_map6_1, png_path + "test_choropleth_map_nyc_6-1.png")
    save_png(choropleth_map6_2, png_path + "test_choropleth_map_nyc_6-2.png")

    # 7 blue_transparency
    vega_7 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "blue_transparency",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline7 = choroplethmap(res, vega_7)
    choropleth_map7_1 = choroplethmap(res, vega_7)
    choropleth_map7_2 = choroplethmap(res, vega_7)

    baseline_png7 = png_path + "choropleth_map_nyc_7.png"
    save_png(baseline7, baseline_png7)
    save_png(choropleth_map7_1, png_path + "test_choropleth_map_nyc_7-1.png")
    save_png(choropleth_map7_2, png_path + "test_choropleth_map_nyc_7-2.png")

    # 8 blue_green_yellow
    vega_8 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "blue_green_yellow",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline8 = choroplethmap(res, vega_8)
    choropleth_map8_1 = choroplethmap(res, vega_8)
    choropleth_map8_2 = choroplethmap(res, vega_8)

    baseline_png8 = png_path + "choropleth_map_nyc_8.png"
    save_png(baseline8, baseline_png8)
    save_png(choropleth_map8_1, png_path + "test_choropleth_map_nyc_8-1.png")
    save_png(choropleth_map8_2, png_path + "test_choropleth_map_nyc_8-2.png")

    # 9 white_blue
    vega_9 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "white_blue",
                                [2.5, 5], 1.0, 'EPSG:4326')
    baseline9 = choroplethmap(res, vega_9)
    choropleth_map9_1 = choroplethmap(res, vega_9)
    choropleth_map9_2 = choroplethmap(res, vega_9)

    baseline_png9 = png_path + "choropleth_map_nyc_9.png"
    save_png(baseline9, baseline_png9)
    save_png(choropleth_map9_1, png_path + "test_choropleth_map_nyc_9-1.png")
    save_png(choropleth_map9_2, png_path + "test_choropleth_map_nyc_9-2.png")

    # 10-12 test ruler
    # 10 ruler: [1, 500]
    vega_10 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "blue_to_red",
                                 [1, 500], 1.0, 'EPSG:4326')
    baseline10 = choroplethmap(res, vega_10)
    choropleth_map10_1 = choroplethmap(res, vega_10)
    choropleth_map10_2 = choroplethmap(res, vega_10)

    baseline_png10 = png_path + "choropleth_map_nyc_10.png"
    save_png(baseline10, baseline_png10)
    save_png(choropleth_map10_1, png_path + "test_choropleth_map_nyc_10-1.png")
    save_png(choropleth_map10_2, png_path + "test_choropleth_map_nyc_10-2.png")

    # 11 ruler: [1, 10000]
    vega_11 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "blue_to_red",
                                 [1, 10000], 1.0, 'EPSG:4326')
    baseline11 = choroplethmap(res, vega_11)
    choropleth_map11_1 = choroplethmap(res, vega_11)
    choropleth_map11_2 = choroplethmap(res, vega_11)

    baseline_png11 = png_path + "choropleth_map_nyc_11.png"
    save_png(baseline11, baseline_png11)
    save_png(choropleth_map11_1, png_path + "test_choropleth_map_nyc_11-1.png")
    save_png(choropleth_map11_2, png_path + "test_choropleth_map_nyc_11-2.png")

    # 12 ruler: [0, 2.5]
    vega_12 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "blue_to_red",
                                 [0, 2.5], 1.0, 'EPSG:4326')
    baseline12 = choroplethmap(res, vega_12)
    choropleth_map12_1 = choroplethmap(res, vega_12)
    choropleth_map12_2 = choroplethmap(res, vega_12)

    baseline_png12 = png_path + "choropleth_map_nyc_12.png"
    save_png(baseline12, baseline_png12)
    save_png(choropleth_map12_1, png_path + "test_choropleth_map_nyc_12-1.png")
    save_png(choropleth_map12_2, png_path + "test_choropleth_map_nyc_12-2.png")

    # 13-15 test opacity
    # 13 opacity: 0.0
    vega_13 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "purple_to_yellow",
                                 [2.5, 5], 0.0, 'EPSG:4326')
    baseline13 = choroplethmap(res, vega_13)
    choropleth_map13_1 = choroplethmap(res, vega_13)
    choropleth_map13_2 = choroplethmap(res, vega_13)

    baseline_png13 = png_path + "choropleth_map_nyc_13.png"
    save_png(baseline13, baseline_png13)
    save_png(choropleth_map13_1, png_path + "test_choropleth_map_nyc_13-1.png")
    save_png(choropleth_map13_2, png_path + "test_choropleth_map_nyc_13-2.png")

    # 14 opacity: 1.0
    vega_14 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "purple_to_yellow",
                                 [2.5, 5], 1.0, 'EPSG:4326')
    baseline14 = choroplethmap(res, vega_14)
    choropleth_map14_1 = choroplethmap(res, vega_14)
    choropleth_map14_2 = choroplethmap(res, vega_14)

    baseline_png14 = png_path + "choropleth_map_nyc_14.png"
    save_png(baseline14, baseline_png14)
    save_png(choropleth_map14_1, png_path + "test_choropleth_map_nyc_14-1.png")
    save_png(choropleth_map14_2, png_path + "test_choropleth_map_nyc_14-2.png")

    # 15 opacity: 0.5
    vega_15 = vega_choroplethmap(1900, 1410, [-73.994092, 40.753893, -73.977588, 40.759642], "purple_to_yellow",
                                 [2.5, 5], 0.5, 'EPSG:4326')
    baseline15 = choroplethmap(res, vega_15)
    choropleth_map15_1 = choroplethmap(res, vega_15)
    choropleth_map15_2 = choroplethmap(res, vega_15)

    baseline_png15 = png_path + "choropleth_map_nyc_15.png"
    save_png(baseline15, baseline_png15)
    save_png(choropleth_map15_1, png_path + "test_choropleth_map_nyc_15-1.png")
    save_png(choropleth_map15_2, png_path + "test_choropleth_map_nyc_15-2.png")

    # 16-18 test size
    # 16 width: 256, height: 256
    vega_16 = vega_choroplethmap(256, 256, [-73.994092, 40.753893, -73.977588, 40.759642], "purple_to_yellow",
                                 [2.5, 5], 1.0, 'EPSG:4326')
    baseline16 = choroplethmap(res, vega_16)
    choropleth_map16_1 = choroplethmap(res, vega_16)
    choropleth_map16_2 = choroplethmap(res, vega_16)

    baseline_png16 = png_path + "choropleth_map_nyc_16.png"
    save_png(baseline16, baseline_png16)
    save_png(choropleth_map16_1, png_path + "test_choropleth_map_nyc_16-1.png")
    save_png(choropleth_map16_2, png_path + "test_choropleth_map_nyc_16-2.png")

    # 17 width: 200, height: 200
    vega_17 = vega_choroplethmap(200, 200, [-73.994092, 40.753893, -73.977588, 40.759642], "purple_to_yellow",
                                 [2.5, 5], 1.0, 'EPSG:4326')
    baseline17 = choroplethmap(res, vega_17)
    choropleth_map17_1 = choroplethmap(res, vega_17)
    choropleth_map17_2 = choroplethmap(res, vega_17)

    baseline_png17 = png_path + "choropleth_map_nyc_17.png"
    save_png(baseline17, baseline_png17)
    save_png(choropleth_map17_1, png_path + "test_choropleth_map_nyc_17-1.png")
    save_png(choropleth_map17_2, png_path + "test_choropleth_map_nyc_17-2.png")

    # 18 width: 500, height: 200
    vega_18 = vega_choroplethmap(500, 200, [-73.994092, 40.753893, -73.977588, 40.759642], "purple_to_yellow",
                                 [2.5, 5], 1.0, 'EPSG:4326')
    baseline18 = choroplethmap(res, vega_18)
    choropleth_map18_1 = choroplethmap(res, vega_18)
    choropleth_map18_2 = choroplethmap(res, vega_18)

    baseline_png18 = png_path + "choropleth_map_nyc_18.png"
    save_png(baseline18, baseline_png18)
    save_png(choropleth_map18_1, png_path + "test_choropleth_map_nyc_18-1.png")
    save_png(choropleth_map18_2, png_path + "test_choropleth_map_nyc_18-2.png")

    # 19 width: 10, height: 10
    vega_19 = vega_choroplethmap(10, 10, [-73.994092, 40.753893, -73.977588, 40.759642], "purple_to_yellow",
                                 [2.5, 5], 1.0, 'EPSG:4326')
    baseline19 = choroplethmap(res, vega_19)
    choropleth_map19_1 = choroplethmap(res, vega_19)
    choropleth_map19_2 = choroplethmap(res, vega_19)

    baseline_png19 = png_path + "choropleth_map_nyc_19.png"
    save_png(baseline19, baseline_png19)
    save_png(choropleth_map19_1, png_path + "test_choropleth_map_nyc_19-1.png")
    save_png(choropleth_map19_2, png_path + "test_choropleth_map_nyc_19-2.png")

    spark.catalog.dropGlobalTempView("nyc_taxi")

    assert run_diff_png(baseline_png1, png_path + "test_choropleth_map_nyc_1-1.png")
    assert run_diff_png(baseline_png1, png_path + "test_choropleth_map_nyc_1-2.png")
    assert run_diff_png(baseline_png2, png_path + "test_choropleth_map_nyc_2-1.png")
    assert run_diff_png(baseline_png2, png_path + "test_choropleth_map_nyc_2-2.png")
    assert run_diff_png(baseline_png3, png_path + "test_choropleth_map_nyc_3-1.png")
    assert run_diff_png(baseline_png3, png_path + "test_choropleth_map_nyc_3-2.png")
    assert run_diff_png(baseline_png4, png_path + "test_choropleth_map_nyc_4-1.png")
    assert run_diff_png(baseline_png4, png_path + "test_choropleth_map_nyc_4-2.png")
    assert run_diff_png(baseline_png5, png_path + "test_choropleth_map_nyc_5-1.png")
    assert run_diff_png(baseline_png5, png_path + "test_choropleth_map_nyc_5-2.png")
    assert run_diff_png(baseline_png6, png_path + "test_choropleth_map_nyc_6-1.png")
    assert run_diff_png(baseline_png6, png_path + "test_choropleth_map_nyc_6-2.png")
    assert run_diff_png(baseline_png7, png_path + "test_choropleth_map_nyc_7-1.png")
    assert run_diff_png(baseline_png7, png_path + "test_choropleth_map_nyc_7-2.png")
    assert run_diff_png(baseline_png8, png_path + "test_choropleth_map_nyc_8-1.png")
    assert run_diff_png(baseline_png8, png_path + "test_choropleth_map_nyc_8-2.png")
    assert run_diff_png(baseline_png9, png_path + "test_choropleth_map_nyc_9-1.png")
    assert run_diff_png(baseline_png9, png_path + "test_choropleth_map_nyc_9-2.png")
    assert run_diff_png(baseline_png10, png_path + "test_choropleth_map_nyc_10-1.png")
    assert run_diff_png(baseline_png10, png_path + "test_choropleth_map_nyc_10-2.png")
    assert run_diff_png(baseline_png11, png_path + "test_choropleth_map_nyc_11-1.png")
    assert run_diff_png(baseline_png11, png_path + "test_choropleth_map_nyc_11-2.png")
    assert run_diff_png(baseline_png12, png_path + "test_choropleth_map_nyc_12-1.png")
    assert run_diff_png(baseline_png12, png_path + "test_choropleth_map_nyc_12-2.png")
    assert run_diff_png(baseline_png13, png_path + "test_choropleth_map_nyc_13-1.png")
    assert run_diff_png(baseline_png13, png_path + "test_choropleth_map_nyc_13-2.png")
    assert run_diff_png(baseline_png14, png_path + "test_choropleth_map_nyc_14-1.png")
    assert run_diff_png(baseline_png14, png_path + "test_choropleth_map_nyc_14-2.png")
    assert run_diff_png(baseline_png15, png_path + "test_choropleth_map_nyc_15-1.png")
    assert run_diff_png(baseline_png15, png_path + "test_choropleth_map_nyc_15-2.png")
    assert run_diff_png(baseline_png16, png_path + "test_choropleth_map_nyc_16-1.png")
    assert run_diff_png(baseline_png16, png_path + "test_choropleth_map_nyc_16-2.png")
    assert run_diff_png(baseline_png17, png_path + "test_choropleth_map_nyc_17-1.png")
    assert run_diff_png(baseline_png17, png_path + "test_choropleth_map_nyc_17-2.png")
    assert run_diff_png(baseline_png18, png_path + "test_choropleth_map_nyc_18-1.png")
    assert run_diff_png(baseline_png18, png_path + "test_choropleth_map_nyc_18-2.png")
    assert run_diff_png(baseline_png19, png_path + "test_choropleth_map_nyc_19-1.png")
    assert run_diff_png(baseline_png19, png_path + "test_choropleth_map_nyc_19-2.png")