Creating an H3 tileset

The tiler is an advance module only for CARTO users; to get access please contact support@carto.com.

Import sample data (optional)

In order to be able to reproduce the following guide, you can optionally import into your Databricks a sample table containing core demographic and environmental data, and POI aggregations by category unified in common geographic H3 support resolution 8.

To do so, please run the following Python script:

%python
import pandas

df = pandas.read_csv("https://storage.googleapis.com/carto-analytics-toolbox-core/samples/derived_spatialfeatures_esp_h3res8_v1_yearly_v2_population.csv")

spark.createDataFrame(df).write.saveAsTable("carto.derived_spatialfeatures_esp_h3res8_v1_yearly_v2_population")

Creating a tileset

As a CARTO Analytics Toolbox module, the Tiler’s capabilities are available as procedures that can be executed directly from your Databricks Notebooks.

To check that your Databricks account has access to the Tiler, try running this query:

%sql
SELECT carto.VERSION_ADVANCED()

Tiler is an advanced module in case of the Analytics Toolbox for Databricks, so it is not open source and requires a specific installation along with a contractual relationship with CARTO.

If you run into any errors when running the query above, contact with our support.

Once you are all set to get access to the Tiler, creating a tileset is as easy as opening your Databricks Notebooks and running a code. In this case, we are going to create a tileset from a table that contains core demographic and environmental data, and POI aggregations by category unified in common geographic H3 support resolution 8:

%scala
import com.carto.analyticstoolbox.modules.tiler.create_spatial_index_tileset

// input values
val source = "carto.derived_spatialfeatures_esp_h3res8_v1_yearly_v2_population"
val target = "carto_dev_data.spatialfeatures_h3tiler_demo"
val options = """{"min_resolution": 0,
  "max_resolution": 4,
  "resolution": 8,
  "aggregation_resolution": 4,
  "spatial_index_column": "h3",
  "properties": {
    "population": {
        "formula":"sum(population)",
        "type":"Number"
    }
  }
}"""

// Execute tiler
create_spatial_index_tileset(source, target, options)

Last updated