public void writeToFile(Path path) throws IOException {
    try (
      var output = new GZIPOutputStream(
        new BufferedOutputStream(Files.newOutputStream(path, CREATE, TRUNCATE_EXISTING, WRITE)));
      var writer = WRITER.writeValues(output)
    ) {
      var sorted = weights.entrySet().stream()
        .sorted(Comparator.comparingInt(e -> e.getKey().encoded()))
        .iterator();
      while (sorted.hasNext()) {
        var entry = sorted.next();
        TileCoord coord = entry.getKey();
        writer.write(new Row(coord.z(), coord.x(), coord.y(), entry.getValue()));
      }
    }
  }
Write tile weights to a gzipped TSV file with {@code z, x, y, loads} columns.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/TileWeights.java