當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。