apache/superset · error · Error

Longitude and latitude columns are required for latlong type

Error message

Longitude and latitude columns are required for latlong type

What it means

Thrown by getSpatialColumns when spatial.type is 'latlong' but lonCol or latCol is missing. The latlong encoding needs two named columns (one for longitude, one for latitude) to emit into the query; either one absent makes the mapping impossible. It is a stricter, type-specific follow-up to the 'Bad spatial key' check.

Source

Thrown at superset-frontend/plugins/preset-chart-deckgl/src/layers/spatialUtils.ts:81

  color_picker?: string;
}

export interface SpatialPoint {
  position: [number, number];
  weight: number;
  extraProps?: Record<string, unknown>;
  [key: string]: unknown;
}

export function getSpatialColumns(spatial: SpatialConfiguration): string[] {
  if (!spatial || !spatial.type) {
    throw new Error('Bad spatial key');
  }

  switch (spatial.type) {
    case 'latlong':
      if (!spatial.lonCol || !spatial.latCol) {
        throw new Error(
          'Longitude and latitude columns are required for latlong type',
        );
      }
      return [spatial.lonCol, spatial.latCol];
    case 'delimited':
      if (!spatial.lonlatCol) {
        throw new Error(
          'Longitude/latitude column is required for delimited type',
        );
      }
      return [spatial.lonlatCol];
    case 'geohash':
      if (!spatial.geohashCol) {
        throw new Error('Geohash column is required for geohash type');
      }
      return [spatial.geohashCol];
    default:
      throw new Error(`Unknown spatial type: ${spatial.type}`);

View on GitHub (pinned to f4587218dd)

Solutions

  1. Set both longitude and latitude columns in the chart's spatial control and save.
  2. Fix programmatic configs so both lonCol and latCol are present whenever type is 'latlong'.
  3. Check saved chart params JSON for typos or half-written spatial objects and correct via the chart API.

Example fix

// before
getSpatialColumns({ type: 'latlong', lonCol: 'lon' }); // throws

// after
getSpatialColumns({ type: 'latlong', lonCol: 'lon', latCol: 'lat' });
Defensive patterns

Strategy: validation

Validate before calling

if (spatial.type === 'latlong' && (!spatial.lonCol || !spatial.latCol)) {
  throw new Error('latlong spatial needs both lonCol and latCol');
}
getSpatialColumns(spatial);

Type guard

const isCompleteLatlong = (s: SpatialConfiguration): boolean =>
  s.type !== 'latlong' || (Boolean(s.lonCol) && Boolean(s.latCol));

Try / catch

try { getSpatialColumns(spatial); } catch (e) { if (e.message.includes('latlong type')) promptForCoordinateColumns(); else throw e; }

Prevention

When it happens

Trigger: A spatial config like { type: 'latlong', lonCol: 'lon' } (latCol missing) reaching getSpatialColumns — typically after one of the two column controls was cleared, or a config built programmatically with only one coordinate field.

Common situations: User sets longitude but not latitude in the spatial control; dataset rename drops one of the two coordinate columns; hand-written form params with a typo (lonCol/latCol keys).

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/523ba73eef8154ff. Report an issue: GitHub.