MCPcopy Index your code
hub / github.com/plotly/plotly.py / _hexagons_to_geojson

Function _hexagons_to_geojson

plotly/figure_factory/_hexbin_map.py:305–323  ·  view source on GitHub ↗

Creates a geojson of hexagonal features based on the outputs of _compute_wgs84_hexbin

(hexagons_lats, hexagons_lons, ids=None)

Source from the content-addressed store, hash-verified

303
304
305def _hexagons_to_geojson(hexagons_lats, hexagons_lons, ids=None):
306 """
307 Creates a geojson of hexagonal features based on the outputs of
308 _compute_wgs84_hexbin
309 """
310 features = []
311 if ids is None:
312 ids = np.arange(len(hexagons_lats))
313 for lat, lon, idx in zip(hexagons_lats, hexagons_lons, ids):
314 points = np.array([lon, lat]).T.tolist()
315 points.append(points[0])
316 features.append(
317 dict(
318 type="Feature",
319 id=idx,
320 geometry=dict(type="Polygon", coordinates=[points]),
321 )
322 )
323 return dict(type="FeatureCollection", features=features)
324
325
326def create_hexbin_map(

Callers 1

create_hexbin_mapFunction · 0.85

Calls 2

tolistMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected