本文整理汇总了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}
示例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"]) ) + "]")