code: def _bins_to_json(h2):
      
      south = h2.get_bin_left_edges(0)
      north = h2.get_bin_right_edges(0)
      west = h2.get_bin_left_edges(1)
      east = h2.get_bin_right_edges(1)
      return {
          "type":"FeatureCollection",
          "features": [
              {
                  "type": "Feature",
                  "geometry": {
                      "type": "Polygon",
                      # Note that folium and GeoJson have them swapped
                      "coordinates": [[
                          [east[j], south[i]],
                          [east[j], north[i]],
                          [west[j], north[i]],
                          [west[j], south[i]],
                          [east[j], south[i]]]],
                  },
                  "properties" : {
                      "count": float(h2.frequencies[i, j])
                  }
              }
              for i in range(h2.shape[0])
              for j in range(h2.shape[1])
          ]
      }
docs: Create GeoJSON representation of histogram bins
  
      Parameters
      ----------
      h2: physt.histogram_nd.Histogram2D
          A histogram of coordinates (in degrees)
  
      Returns
      -------
      geo_json : dict