예제 #1
0
def test_iconviz():
    x_data = []
    y_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)

    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)

    import os
    dir_path = os.path.dirname(os.path.realpath(__file__))
    png_path = dir_path + "/../images/taxi.png"

    ax = _get_matplot()
    ap.plot.iconviz(ax,
                    points,
                    bounding_box=bounding_box,
                    icon_path=png_path,
                    coordinate_system="EPSG:4326")
    _finalize(ax, "test_icon_viz")
예제 #2
0
def test_point_map():
    x_data = []
    y_data = []

    # y = 150
    for i in range(100, 200):
        x_data.append(i)
        y_data.append(150)

    # y = x - 50
    for i in range(100, 200):
        x_data.append(i)
        y_data.append(i - 50)

    # y = 50
    for i in range(100, 200):
        x_data.append(i)
        y_data.append(50)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)

    vega = vega_pointmap(
        1024,
        896,
        bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816],
        point_size=3,
        point_color="#2DEF4A",
        opacity=0.5,
        coordinate_system="EPSG:4326")
    curve_z1 = arctern.point_map(vega, points)
    save_png(curve_z1, "/tmp/test_curve_z1.png")
예제 #3
0
파일: geo_test.py 프로젝트: shengjh/arctern
def test_ST_Point():
    data1 = pandas.Series([1.3, 2.5])
    data2 = pandas.Series([3.8, 4.9])
    string_ptr = arctern.ST_AsText(arctern.ST_Point(data1, data2))
    assert len(string_ptr) == 2
    assert string_ptr[0] == "POINT (1.3 3.8)"
    assert string_ptr[1] == "POINT (2.5 4.9)"
예제 #4
0
def test_heat_map():
    x_data = []
    y_data = []
    c_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)

    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    c_data.append(10)
    c_data.append(20)
    c_data.append(30)
    c_data.append(40)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    arr_c = pandas.Series(c_data)
    points = arctern.ST_Point(arr_x, arr_y)

    vega = vega_heatmap(
        1024,
        896,
        bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816],
        map_zoom_level=13.0,
        coordinate_system='EPSG:4326')
    heat_map1 = arctern.heat_map_layer(vega, points, arr_c)

    save_png(heat_map1, "/tmp/test_heat_map1.png")
예제 #5
0
def test_icon_viz():
    x_data = []
    y_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)

    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)

    import os
    dir_path = os.path.dirname(os.path.realpath(__file__))
    png_path = dir_path + "/../images/taxi.png"

    vega = vega_icon(
        1024,
        896,
        bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816],
        icon_path=png_path,
        coordinate_system="EPSG:4326")

    icon_buf = arctern.icon_viz_layer(vega, points)
    save_png(icon_buf, "/tmp/test_icon_viz.png")
예제 #6
0
def test_pointmap():
    x_data = []
    y_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)
    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)
    ax = _get_matplot()
    ap.plot.pointmap(ax,
                     points,
                     bounding_box=bounding_box,
                     point_size=10,
                     point_color="#0000FF",
                     opacity=1.0,
                     coordinate_system="EPSG:4326")
    _finalize(ax, "test_point_map")
예제 #7
0
def test_point_map():
    x_data = []
    y_data = []

    # y = 150
    for i in range(100, 200):
        x_data.append(i)
        y_data.append(150)

    # y = x - 50
    for i in range(100, 200):
        x_data.append(i)
        y_data.append(i - 50)

    # y = 50
    for i in range(100, 200):
        x_data.append(i)
        y_data.append(50)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)

    vega = vega_pointmap(1024, 896, [-73.998427, 40.730309, -73.954348, 40.780816], 3, "#2DEF4A", 0.5, "EPSG:4326")
    curve_z1 = arctern.point_map(vega, points)
    save_png(curve_z1, "/tmp/test_curve_z1.png")
예제 #8
0
    def point(cls, x, y, crs=None):
        """
        Construct Point geometries according to the coordinates.

        :type x: Series(dtype: float64)
        :param x: Abscissa of the point.

        :type y: Series(dtype: float64)
        :param y: Ordinate of the point.

        :type crs: string, optional
        :param crs: Must be SRID format string.

        :rtype: GeoSeries
        :return: A GeoSeries contains point geometries.

        :example:
        >>> from pandas import Series
        >>> from arctern import GeoSeries
        >>> x = Series([1.3, 2.5])
        >>> y = Series([1.3, 2.5])
        >>> GeoSeries.point(x, y)
        0    POINT (1.3 1.3)
        1    POINT (2.5 2.5)
        dtype: GeoDtype
        """
        crs = _validate_crs(crs)
        return cls(arctern.ST_Point(x, y), crs=crs)
예제 #9
0
def test_fishnet_map():
    x_data = []
    y_data = []
    c_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)

    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    c_data.append(10)
    c_data.append(20)
    c_data.append(30)
    c_data.append(40)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    arr_c = pandas.Series(c_data)
    points = arctern.ST_Point(arr_x, arr_y)

    ax = _get_matplot()
    ap.plot_fishnetmap(ax, points, arr_c, bounding_box=bounding_box, color_gradient=["#0000FF", "#FF0000"], cell_size=4, cell_spacing=1, opacity=1.0, coordinate_system='EPSG:4326')
    _finalize(ax, "test_fishnetmap")
예제 #10
0
def test_heatmap():
    x_data = []
    y_data = []
    c_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)

    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    c_data.append(10)
    c_data.append(20)
    c_data.append(30)
    c_data.append(40)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    arr_c = pandas.Series(c_data)
    points = arctern.ST_Point(arr_x, arr_y)

    ax = _get_matplot()
    ap.plot.heatmap(ax,
                    points,
                    arr_c,
                    bounding_box=bounding_box,
                    map_zoom_level=13,
                    coordinate_system='EPSG:4326')
    _finalize(ax, "test_heat_map1")
예제 #11
0
def test_point_map():
    x_data = []
    y_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)
    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)

    vega = vega_pointmap(
        1024,
        896,
        bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816],
        point_size=10,
        point_color="#0000FF",
        opacity=1.0,
        coordinate_system="EPSG:4326")
    curve_z1 = arctern.point_map_layer(vega, points)
    save_png(curve_z1, "/tmp/test_curve_z1.png")
예제 #12
0
def test_ST_Point():
    geo1 = 1.1
    geo2 = 2.1
    arr1 = [geo1 for x in range(1, 10000001)]
    arr2 = [geo2 for x in range(1, 10000001)]

    data1 = pandas.Series(arr1)
    data2 = pandas.Series(arr2)
    rst = arctern.ST_AsText(arctern.ST_Point(data1, data2))
    assert len(rst) == 10000000
예제 #13
0
def test_ST_Point():
    data1 = pandas.Series([1.3, 2.5])
    data2 = pandas.Series([3.8, 4.9])
    string_ptr = arctern.ST_AsText(arctern.ST_Point(data1, data2))
    assert len(string_ptr) == 2
    assert string_ptr[0] == "POINT (1.3 3.8)"
    assert string_ptr[1] == "POINT (2.5 4.9)"

    string_ptr = arctern.ST_AsText(arctern.ST_Point(pandas.Series([1, 2], dtype='double'), 5))
    assert len(string_ptr) == 2
    assert string_ptr[0] == "POINT (1 5)"
    assert string_ptr[1] == "POINT (2 5)"

    string_ptr = arctern.ST_AsText(arctern.ST_Point(5, pandas.Series([1, 2], dtype='double')))
    assert len(string_ptr) == 2
    assert string_ptr[0] == "POINT (5 1)"
    assert string_ptr[1] == "POINT (5 2)"

    string_ptr = arctern.ST_AsText(arctern.ST_Point(5.0, 1.0))
    assert len(string_ptr) == 1
    assert string_ptr[0] == "POINT (5 1)"
예제 #14
0
def test_weighted_point_map():
    x_data = []
    y_data = []
    c_data = []
    s_data = []

    x_data.append(10)
    x_data.append(20)
    x_data.append(30)
    x_data.append(40)
    x_data.append(50)

    y_data.append(10)
    y_data.append(20)
    y_data.append(30)
    y_data.append(40)
    y_data.append(50)

    c_data.append(1)
    c_data.append(2)
    c_data.append(3)
    c_data.append(4)
    c_data.append(5)

    s_data.append(2)
    s_data.append(4)
    s_data.append(6)
    s_data.append(8)
    s_data.append(10)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)
    arr_c = pandas.Series(c_data)
    arr_s = pandas.Series(s_data)

    vega1 = vega_weighted_pointmap(300, 200, [-73.998427, 40.730309, -73.954348, 40.780816], ["#87CEEB"], [1, 5], [5], 1.0, "EPSG:3857")
    res1 = arctern.weighted_point_map(vega1, points)
    save_png(res1, "/tmp/test_weighted_0_0.png")

    vega2 = vega_weighted_pointmap(300, 200, [-73.998427, 40.730309, -73.954348, 40.780816], ["#0000FF", "#FF0000"], [1, 5], [5], 1.0, "EPSG:3857")
    res2 = arctern.weighted_point_map(vega2, points, color_weights=arr_c)
    save_png(res2, "/tmp/test_weighted_1_0.png")

    vega3 = vega_weighted_pointmap(300, 200, [-73.998427, 40.730309, -73.954348, 40.780816], ["#87CEEB"], [1, 5], [1, 10], 1.0, "EPSG:3857")
    res3 = arctern.weighted_point_map(vega3, points, size_weights=arr_s)
    save_png(res3, "/tmp/test_weighted_0_1.png")

    vega4 = vega_weighted_pointmap(300, 200, [-73.998427, 40.730309, -73.954348, 40.780816], ["#0000FF", "#FF0000"], [1, 5], [1, 10], 1.0, "EPSG:3857")
    res4 = arctern.weighted_point_map(vega4, points, color_weights=arr_c, size_weights=arr_s)
    save_png(res4, "/tmp/test_weighted_1_1.png")
예제 #15
0
def test_weighted_pointmap():
    x_data = []
    y_data = []
    c_data = []
    s_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)

    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    c_data.append(1)
    c_data.append(2)
    c_data.append(3)
    c_data.append(4)

    s_data.append(4)
    s_data.append(6)
    s_data.append(8)
    s_data.append(10)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)
    arr_c = pandas.Series(c_data)
    arr_s = pandas.Series(s_data)

    ax = _get_matplot()
    ap.plot_weighted_pointmap(ax, points, bounding_box=bounding_box, color_gradient=[
                              "#0000FF"], opacity=1.0, coordinate_system="EPSG:4326")
    _finalize(ax, "test_weighted_0_0")

    ax = _get_matplot()
    ap.plot_weighted_pointmap(ax, points, color_weights=arr_c, bounding_box=bounding_box, color_gradient=[
                              "#0000FF", "#FF0000"], color_bound=[1, 5], opacity=1.0, coordinate_system="EPSG:4326")
    _finalize(ax, "test_weighted_1_0")

    ax = _get_matplot()
    ap.plot_weighted_pointmap(ax, points, size_weights=arr_s, bounding_box=bounding_box, color_gradient=[
                              "#0000FF"], size_bound=[1, 10], opacity=1.0, coordinate_system="EPSG:4326")
    _finalize(ax, "test_weighted_0_1")

    ax = _get_matplot()
    ap.plot_weighted_pointmap(ax, points, color_weights=arr_c, size_weights=arr_s, bounding_box=bounding_box, color_gradient=[
                              "#0000FF", "#FF0000"], color_bound=[1, 5], size_bound=[1, 10], opacity=1.0, coordinate_system="EPSG:4326")
    _finalize(ax, "test_weighted_1_1")
예제 #16
0
def test_weighted_point_map():
    x_data = []
    y_data = []
    c_data = []
    s_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)

    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    c_data.append(1)
    c_data.append(2)
    c_data.append(3)
    c_data.append(4)

    s_data.append(4)
    s_data.append(6)
    s_data.append(8)
    s_data.append(10)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)
    arr_c = pandas.Series(c_data)
    arr_s = pandas.Series(s_data)

    vega1 = vega_weighted_pointmap(1024, 896, bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816], color_gradient=["#0000FF"], opacity=1.0, coordinate_system="EPSG:4326")
    res1 = arctern.weighted_point_map_layer(vega1, points)
    save_png(res1, "/tmp/test_weighted_0_0.png")

    vega2 = vega_weighted_pointmap(1024, 896, bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816], color_gradient=["#0000FF", "#FF0000"], color_bound=[1, 5], opacity=1.0, coordinate_system="EPSG:4326")
    res2 = arctern.weighted_point_map_layer(vega2, points, color_weights=arr_c)
    save_png(res2, "/tmp/test_weighted_1_0.png")

    vega3 = vega_weighted_pointmap(1024, 896, bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816], color_gradient=["#0000FF"], size_bound=[1, 10], opacity=1.0, coordinate_system="EPSG:4326")
    res3 = arctern.weighted_point_map_layer(vega3, points, size_weights=arr_s)
    save_png(res3, "/tmp/test_weighted_0_1.png")

    vega4 = vega_weighted_pointmap(1024, 896, bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816], color_gradient=["#0000FF", "#FF0000"], color_bound=[1, 5], size_bound=[1, 10], opacity=1.0, coordinate_system="EPSG:4326")
    res4 = arctern.weighted_point_map_layer(vega4, points, color_weights=arr_c, size_weights=arr_s)
    save_png(res4, "/tmp/test_weighted_1_1.png")
예제 #17
0
def test_heat_map():
    x_data = []
    y_data = []
    c_data = []

    for i in range(0, 5):
        x_data.append(i + 50)
        y_data.append(i + 50)
        c_data.append(i + 50)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)
    arr_c = pandas.Series(y_data)

    vega = vega_heatmap(1024, 896, [-73.998427, 40.730309, -73.954348, 40.780816], 10.0, 'EPSG:4326')
    heat_map1 = arctern.heat_map(vega, points, arr_c)

    save_png(heat_map1, "/tmp/test_heat_map1.png")
예제 #18
0
def test_icon_viz():
    x_data = []
    y_data = []

    for i in range(5):
        x_data.append(i * 100)
        y_data.append(i * 100)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    points = arctern.ST_Point(arr_x, arr_y)

    import os
    dir_path = os.path.dirname(os.path.realpath(__file__))
    png_path = dir_path + "/../images/taxi.png"

    vega = vega_icon(800, 600, [-73.998427, 40.730309, -73.954348, 40.780816],
                     png_path, "EPSG:43")

    icon_buf = arctern.icon_viz(vega, points)
    save_png(icon_buf, "/tmp/test_icon_viz.png")
예제 #19
0
def test_fishnet_map():
    x_data = []
    y_data = []
    c_data = []

    x_data.append(-73.96524)
    x_data.append(-73.96118)
    x_data.append(-73.97324)
    x_data.append(-73.98456)

    y_data.append(40.73747)
    y_data.append(40.74507)
    y_data.append(40.75890)
    y_data.append(40.77654)

    c_data.append(10)
    c_data.append(20)
    c_data.append(30)
    c_data.append(40)

    arr_x = pandas.Series(x_data)
    arr_y = pandas.Series(y_data)
    arr_c = pandas.Series(c_data)
    points = arctern.ST_Point(arr_x, arr_y)

    vega = vega_fishnetmap(
        1024,
        896,
        bounding_box=[-73.998427, 40.730309, -73.954348, 40.780816],
        color_gradient=["#0000FF", "#FF0000"],
        cell_size=4,
        cell_spacing=1,
        opacity=1.0,
        coordinate_system='EPSG:4326')
    heat_map1 = arctern.fishnet_map_layer(vega, points, arr_c)

    save_png(heat_map1, "/tmp/test_fishnetmap.png")
예제 #20
0
def ST_Point(x, y):
    return arctern.ST_Point(x, y)
예제 #21
0
def python_test(data1, data2):
    TIME_START(func_name)
    arctern.ST_AsText(arctern.ST_Point(data1, data2))
    TIME_END(func_name)

    return TIME_INFO()