mrdoob/three.js · error
unsupported shape type: ${type}
Error message
unsupported shape type: ${type} What it means
Thrown by the Shp constructor when the .shp file header's shape-type code (little-endian int32 at byte offset 32) is not a key in the parsers map. Supported codes are 0 (Null), 1/11/21 (Point variants), 3/13/23 (PolyLine), 5/15/25 (Polygon), and 8/18/28 (MultiPoint). Any other value — including future/proprietary shape types — is rejected at parse time.
Source
Thrown at manual/resources/tools/geo-picking/shapefile.js:372
13: parsePolyLine, // PolyLineZ
15: parsePolygon, // PolygonZ
18: parseMultiPoint, // MultiPointZ
21: parsePoint, // PointM
23: parsePolyLine, // PolyLineM
25: parsePolygon, // PolygonM
28: parseMultiPoint // MultiPointM
};
var shp = function(source) {
source = slice(source);
return source.slice(100).then(function(array) {
return new Shp(source, view(array));
});
};
function Shp(source, header) {
var type = header.getInt32(32, true);
if (!(type in parsers)) throw new Error("unsupported shape type: " + type);
this._source = source;
this._type = type;
this._index = 0;
this._parse = parsers[type];
this.bbox = [header.getFloat64(36, true), header.getFloat64(44, true), header.getFloat64(52, true), header.getFloat64(60, true)];
}
var prototype$2 = Shp.prototype;
prototype$2.read = shp_read;
prototype$2.cancel = cancel;
function noop() {}
var shapefile_cancel = function() {
return Promise.all([
this._dbf && this._dbf.cancel(),
this._shp.cancel()
]).then(noop);View on GitHub (pinned to da05705fa3)
Solutions
- Confirm the input file is a valid .shp and inspect its declared type code (read int32 LE at offset 32).
- If the type is genuinely one you need (e.g. 31 MultiPatch), add a parser function and register it in the parsers map at shapefile.js:347.
- If the file is corrupt, re-export the shapefile from QGIS/GDAL as a supported type (Polygon, PolyLine, Point).
Example fix
// before — file declares type 31 (MultiPatch), not in parsers
var parsers = { 0: parseNull, 1: parsePoint, /* ... 28: parseMultiPoint */ };
// after — add a parser for the type you need
var parsers = {
0: parseNull, 1: parsePoint, /* ... */ 28: parseMultiPoint,
31: parseMultiPatch,
}; Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_SHP_TYPES = new Set( [ 0, 1, 3, 5, 8, 11, 13, 15, 18, 21, 23, 25, 28 ] );
function assertShpType( type ) {
if ( ! SUPPORTED_SHP_TYPES.has( type ) ) {
throw new Error( `unsupported shape type: ${type}` );
}
} Type guard
const SUPPORTED_SHP_TYPES = new Set( [ 0, 1, 3, 5, 8, 11, 13, 15, 18, 21, 23, 25, 28 ] );
function isSupportedShpType( type ) {
return SUPPORTED_SHP_TYPES.has( type );
} Try / catch
try {
shp = await shp( source );
} catch ( err ) {
if ( /unsupported shape type/.test( err.message ) ) {
throw new Error( 'This shapefile uses a geometry type the reader cannot handle. Re-export as Polygon/PolyLine/Point.' );
}
throw err;
} Prevention
- Inspect the .shp header type code (int32 LE at offset 32) before parsing.
- Register a parser in the parsers map (shapefile.js:347) for any new type you need.
- Re-export exotic shapefiles (e.g. MultiPatch) to a supported type via GDAL/QGIS.
When it happens
Trigger: Reading a .shp file whose declared shape type is outside the ESRI types the reader implements (e.g. type 31 MultiPatch, or any vendor-specific code). Reading a corrupt .shp where the bytes at offset 32 do not form a valid type code.
Common situations: Using a natural-earth or OSM-derived shapefile that happens to use MultiPatch (3D multipatch, type 31). Feeding a non-.shp binary (or a .shx/.dbf) to the .shp parser so the type field is random.
Related errors
- invalid length
- unknown type for ${primitiveName}:${ndx} param: ${name}
- unknown geometry type.
- THREE.KeyframeTrack: Unsupported typeName: ${typeName}
- setTitle: Unknown script
AI-assisted analysis of mrdoob/three.js@da05705fa3 (2026-08-12).
Data as JSON: /api/errors/e89a28a833c43236.
Report an issue: GitHub.