Colors 使用geojson.Feature时如何设置标记颜色
我正在使用python,我的代码如下:Colors 使用geojson.Feature时如何设置标记颜色,colors,geojson,marker,Colors,Geojson,Marker,我正在使用python,我的代码如下: from geojson import Feature, FeatureCollection import json import sys, pymongo db = pymongo.MongoClient(host = '..........').database coll_name = sys.argv[1] point_list = [] citymap_cursor = db[coll_name].find() for doc in city
from geojson import Feature, FeatureCollection
import json
import sys, pymongo
db = pymongo.MongoClient(host = '..........').database
coll_name = sys.argv[1]
point_list = []
citymap_cursor = db[coll_name].find()
for doc in citymap_cursor:
point_list.append(Feature(geometry=doc['point_latlng']))
with open('/path to/%s.json' % coll_name, 'w+') as outfile:
json.dump(FeatureCollection(point_list), outfile)
通过这段代码,我得到了一批点,我可以使用geojson.io来可视化这些点。现在,geojson.io上的这些点标记是灰色的,但我希望它们是红色的。我想知道这些是否是geojson.Feature中关于颜色的属性,以便我可以调整标记颜色?是的,您可以使用
属性
对象内的标记颜色
键操纵标记颜色。您向它传递一个十六进制颜色,如{“marker color”:“#FFF”}
。我假设您将在城市地图中的文档的游标中执行此操作:
循环-类似于point\u list.append(Feature(geometry=doc['point\u latlng',properties={'marker-color':'FFF'))