Dear Bokeh-ers,

Sorry if this is a silly question, but I’m trying to create some graphics which will include coloring a map of Europe, and I’m stuck on a seemingly basic problem.

I’m trying to use the GeoPandas naturalearth_lowres database of countries to extract the ones I’m interested in. The countries geometries are stored mostly as Polygon objects, but occasionally as MultiPolygons. Which is where my problem starts.

I’m trying to tease out the x and y coordinates in the way bokeh requires, but get stuck trying to extract them from MultiPolygons. I found the following helper function (from https://automating-gis-processes.github.io/Lesson5-interactive-map-Bokeh-advanced-plotting.html):

```
def multiGeomHandler(multi_geometry, coord_type, geom_type):
"""
Function for handling multi-geometries. Can be MultiPoint, MultiLineString or MultiPolygon.
Returns a list of coordinates where all parts of Multi-geometries are merged into a single list.
Individual geometries are separated with np.nan which is how Bokeh wants them.
# Bokeh documentation regarding the Multi-geometry issues can be found here (it is an open issue)
# https://github.com/bokeh/bokeh/issues/2321
"""
for i, part in enumerate(multi_geometry):
# On the first part of the Multi-geometry initialize the coord_array (np.array)
if i == 0:
if geom_type == "MultiPoint":
coord_arrays = np.append(getPointCoords(part, coord_type), np.nan)
elif geom_type == "MultiLineString":
coord_arrays = np.append(getLineCoords(part, coord_type), np.nan)
elif geom_type == "MultiPolygon":
coord_arrays = np.append(getPolyCoords(part, coord_type), np.nan)
else:
if geom_type == "MultiPoint":
coord_arrays = np.concatenate([coord_arrays, np.append(getPointCoords(part, coord_type), np.nan)])
elif geom_type == "MultiLineString":
coord_arrays = np.concatenate([coord_arrays, np.append(getLineCoords(part, coord_type), np.nan)])
elif geom_type == "MultiPolygon":
coord_arrays = np.concatenate([coord_arrays, np.append(getPolyCoords(part, coord_type), np.nan)])
# Return the coordinates
return coord_arrays
```

```
```

However, these np.nans, unlike what’s stated at the comment, are throwing errors: They are not recognized by JSON. I tried replacing them with None, other meaningless values (inf), empty lists or tuples, or just 0. This is the closest I got (when replacing np.nan with the empty list ):

Any advice on what I might be missing, or how to get rid of those superfluous lines? I can imagine why they appear, but can’t find a way to simply make it work.

Thanks in advance for any thought! I know it shouldn’t be this difficult.