<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create H3 hexagons Mosaic in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/create-h3-hexagons-mosaic/m-p/31759#M23136</link>
    <description>&lt;P&gt;This only shows a sample, hence the gap between the hexagons. &lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2022 08:40:05 GMT</pubDate>
    <dc:creator>shanakap</dc:creator>
    <dc:date>2022-09-15T08:40:05Z</dc:date>
    <item>
      <title>Create H3 hexagons Mosaic</title>
      <link>https://community.databricks.com/t5/data-engineering/create-h3-hexagons-mosaic/m-p/31758#M23135</link>
      <description>&lt;P&gt;I am new to using&amp;nbsp;`Mosaic`&amp;nbsp;on&amp;nbsp;Databricks. The task is to create a Heatmap with the counts within Hexagons of H3 resolution. Since the dataset is quite large I am opting for&amp;nbsp;Mosaic. As the first step I am trying to create the hexagons covering the given area but the following  code does not generate hexagons covering the full square as illustrated below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from pyspark.sql.functions import *
from mosaic import enable_mosaic
enable_mosaic(spark, dbutils)
&amp;nbsp;
from pyspark import SparkContext
from pyspark.sql import functions as F
import mosaic as mos
&amp;nbsp;
&amp;nbsp;
from mosaic import st_point
&amp;nbsp;
lons = [-80., -80., -70., -70., -80.]
lats = [ 35.,  45.,  45.,  35.,  35.]
&amp;nbsp;
bounds_df = (
  spark
  .createDataFrame({"lon": lon, "lat": lat} for lon, lat in zip(lons, lats))
  .coalesce(1)
  .withColumn("point_geom", st_point("lon", "lat"))
)
bounds_df.show()
&amp;nbsp;
from mosaic import st_makeline
&amp;nbsp;
bounds_df = (
  bounds_df
  .groupBy()
  .agg(F.collect_list("point_geom").alias("bounding_coords"))
  .select(st_makeline("bounding_coords").alias("bounding_ring"))
)
bounds_df.show()
&amp;nbsp;
from mosaic import st_makepolygon
&amp;nbsp;
bounds_df = bounds_df.select(st_makepolygon("bounding_ring").alias("bounds"))
bounds_df.show()
&amp;nbsp;
&amp;nbsp;
hexs = (bounds_df
       .select(mos.mosaic_explode("bounds", lit(5)))
       .select("index.*")
    )
&amp;nbsp;
hexs.show()
&amp;nbsp;
%%mosaic_kepler
hexs "index_id" "h3"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="2ATLt"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1500iAFF27DD01C76651E/image-size/large?v=v2&amp;amp;px=999" role="button" title="2ATLt" alt="2ATLt" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know why there are gaps between the hexagons? &lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 08:32:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/create-h3-hexagons-mosaic/m-p/31758#M23135</guid>
      <dc:creator>shanakap</dc:creator>
      <dc:date>2022-09-14T08:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create H3 hexagons Mosaic</title>
      <link>https://community.databricks.com/t5/data-engineering/create-h3-hexagons-mosaic/m-p/31759#M23136</link>
      <description>&lt;P&gt;This only shows a sample, hence the gap between the hexagons. &lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 08:40:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/create-h3-hexagons-mosaic/m-p/31759#M23136</guid>
      <dc:creator>shanakap</dc:creator>
      <dc:date>2022-09-15T08:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create H3 hexagons Mosaic</title>
      <link>https://community.databricks.com/t5/data-engineering/create-h3-hexagons-mosaic/m-p/31760#M23137</link>
      <description>&lt;P&gt;Hi @Shanaka Pererea​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 07:08:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/create-h3-hexagons-mosaic/m-p/31760#M23137</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-28T07:08:18Z</dc:date>
    </item>
  </channel>
</rss>

