Prepping Your Database

Your PostgreSQL database needs to have the PostGIS extension enabled and contain some geospatial data to serve. Let's get our database ready.

  1. Connect to your PostgreSQL database using your favorite client (pgAdmin, DBeaver, or psql).

  2. Enable PostGIS by running this simple command:

    CREATE EXTENSION IF NOT EXISTS postgis;
    
  3. Prepare your data. For this tutorial, we will assume you have a table named places with a geometry column named geom (using EPSG:3857).

[!IMPORTANT] Pro Tip: MVT tiles rely heavily on the EPSG:3857 (Web Mercator) coordinate system. Ensure your geometry column is projected in EPSG:3857, or cast it dynamically in your SQL query using ST_Transform(geom, 3857). Also, always add a spatial index (GIST) to your geometry column for performance, or your tiles will take forever to load!

← Previous