I’m using a Puerto Rico geojson for a scatter map, and I’m passing the coordinates into Scattergeo. Is it possible for me to color the map this way? I have the color property inside of the geojson file. I just want the map to look similar to plotly’s default scattermap.
# load pr json
with open('../puerto_rico.geojson') as f:
pr_geojson = json.load(f)
# get boundaries for puerto rico
pts = []
for feature in pr_geojson['features']:
if feature['geometry']['type'] == 'Polygon':
pts.extend(feature['geometry']['coordinates'][0])
pts.append([None, None])#mark the end of a polygon
elif feature['geometry']['type'] == 'MultiPolygon':
for polyg in feature['geometry']['coordinates']:
pts.extend(polyg[0])
pts.append([None, None])#end of polygon
elif feature['geometry']['type'] == 'LineString':
points.extend(feature['geometry']['coordinates'])
points.append([None, None])
else: pass
x, y = zip(*pts)
data = []
# create pr map
data.append(
go.Scattergeo(
lon = x,
lat = y,
mode="lines",
line_width=1.5,
line_color="blue",
)
)
fig = go.Figure(data=data)
fig.update_layout(height=800, margin={"r":0,"t":0,"l":0,"b":0})
fig.update_geos(visible=False)
fig.show()