当前位置: 首页>>代码示例>>Python>>正文


Python GeoJSON.getFeature方法代码示例

本文整理汇总了Python中geojson.GeoJSON.getFeature方法的典型用法代码示例。如果您正苦于以下问题:Python GeoJSON.getFeature方法的具体用法?Python GeoJSON.getFeature怎么用?Python GeoJSON.getFeature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geojson.GeoJSON的用法示例。


在下文中一共展示了GeoJSON.getFeature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GeoJSON

# 需要导入模块: from geojson import GeoJSON [as 别名]
# 或者: from geojson.GeoJSON import getFeature [as 别名]
    geojson = GeoJSON()
    output = geojson.getFormat()

    progress = Progress( len(dataset_1) )
    progress.progressBar("Conversioning")
    for i in range( len(dataset_1) ):
        if dataset_1[i][5] > threshold_1 and dataset_2[i][5] > threshold_2:
            red = int( ( log(dataset_1[i][5]) / log(max_1) ) * 255 )
            blue = int( ( log(dataset_2[i][5]) / log(max_2) ) * 255 )
            color = "rgba(" + str(red) + ", 0, " + str(blue) + ", 0.5)"
            output["features"].append( geojson.getFeature("Polygon",
                                                          [[ [dataset_1[i][2], dataset_1[i][1]],
                                                             [dataset_1[i][2], dataset_1[i][3]],
                                                             [dataset_1[i][4], dataset_1[i][3]],
                                                             [dataset_1[i][4], dataset_1[i][1]] ]],
                                                             { "color": color,
                                                               "twitter": {"population": dataset_1[i][5]},
                                                               "flickr": {"population": dataset_2[i][5]}
                                                             }) )
        elif dataset_1[i][5] > threshold_1:
            red = int( ( log(dataset_1[i][5]) / log(max_1) ) * 255 )
            color = "rgba(" + str(red) + ", 0, 0, 0.5)"
            output["features"].append( geojson.getFeature("Polygon",
                                                          [[ [dataset_1[i][2], dataset_1[i][1]],
                                                             [dataset_1[i][2], dataset_1[i][3]],
                                                             [dataset_1[i][4], dataset_1[i][3]],
                                                             [dataset_1[i][4], dataset_1[i][1]] ]],
                                                             { "color": color,
                                                               "twitter": {"population": dataset_1[i][5]},
                                                               "flickr": {"population": 0}
开发者ID:yuusaku0213,项目名称:python_project,代码行数:32,代码来源:conversion_mix.py

示例2: GeoJSON

# 需要导入模块: from geojson import GeoJSON [as 别名]
# 或者: from geojson.GeoJSON import getFeature [as 别名]
    geojson = GeoJSON()
    output = geojson.getFormat()

    dataset = json.loads(input_text)
    progress = Progress( len(dataset) )
    progress.progressBar("Conversioning")
    for data in dataset:
        if data[5] > threshold:
            alpha = log(data[5]) / log(max_value)
            if (data_source == "twitter"):
                color = "rgba(255, 0, 0, " + str(alpha) + ")"
            elif (data_source == "flickr"):
                color = "rgba(0, 0, 255, " + str(alpha) + ")"

            output["features"].append( geojson.getFeature("Polygon",
                                                          [[ [data[2], data[1]], [data[2], data[3]],
                                                            [data[4], data[3]], [data[4], data[1]] ]],
                                                            { "color": color,
                                                              "population": data[5],
                                                              "text": data[6] }) )
        progress.tick(1)

    output_text = json.dumps(output, indent=4)

    output_path = 'json/' + output_file + '.json'
    with open(output_path, 'w') as f:
        f.write(output_text)

    print("[" + str( len(output["features"]) ) + "]")
开发者ID:yuusaku0213,项目名称:python_project,代码行数:31,代码来源:conversion.py


注:本文中的geojson.GeoJSON.getFeature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。