pentaho/pentaho-kettle · error · GisException

shape type : not recognized! ( )

Error message

shape type : ${btype} not recognized! (${typeDesc})

What it means

ShapeFile.readFile parses each shape record's type code and constructs the matching Shape subclass; the default branch throws a GisException for any type code not in the recognized switch cases. Unlike the reader step, this low-level class supports an even narrower set of types (e.g. Point, Polygon, PolylineM).

Solutions

  1. Inspect the file's shape type (ogrinfo -so or the 5th int in the .shp main header) and convert it to a supported type (e.g. ogr2ogr with a type conversion).
  2. Use a different, more complete shapefile library (GeoTools, GDAL) for unsupported types.
  3. Extend ShapeFile.readFile with a case constructing the appropriate Shape subclass.
  4. Skip or quarantine records with unrecognized type codes before parsing.

Example fix

// before
ogr2ogr -f "ESRI Shapefile" out.shp in3d.shp   // keeps Z type 15
// after
ogr2ogr -f "ESRI Shapefile" -nlt POLYGON out.shp in3d.shp   // downgrades to type 5
Defensive patterns

Strategy: validation

Validate before calling

byte[] header = new byte[100];
try ( RandomAccessFile raf = new RandomAccessFile( shp, "r" ) ) { raf.readFully( header ); }
int type = ByteBuffer.wrap( header ).order( ByteOrder.LITTLE_ENDIAN ).getInt( 32 );
Set<Integer> supported = Set.of( 1, 3, 4, 5, 13 ); // match ShapeFile's switch
if ( !supported.contains( type ) ) throw new IllegalStateException( "Unsupported shape type code " + type );

Try / catch

try {
  shapeFile.readFile();
} catch ( GisException e ) {
  log.error( "Shape type unsupported or file unreadable: " + e.getMessage(), e );
}

Prevention

When it happens

Trigger: Reading a .shp whose binary shape type field (btype from the record header) is not one of the supported SHAPE_TYPE_* constants — e.g. MultiPoint, MultiPatch, PointZ, PolygonZ.

Common situations: Processing 3D/measure shapefiles (Z/M types), MultiPoint or MultiPatch exports from CAD/GIS tools, or files whose type field is corrupt.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/936ff9220ad79248. Report an issue: GitHub.

Appendix: source

Thrown at plugins/shapefilereader/core/src/main/java/org/pentaho/gis/shapefiles/ShapeFile.java:140

          switch ( btype ) {
            case Shape.SHAPE_TYPE_NULL:
              esi = new ShapeNull( content );
              break;
            case Shape.SHAPE_TYPE_POINT:
              esi = new ShapePoint( content );
              break;
            case Shape.SHAPE_TYPE_POLYLINE:
              esi = new ShapePolyLine( content );
              break;
            case Shape.SHAPE_TYPE_POLYGON:
              esi = new ShapePolygon( content );
              break;
            case Shape.SHAPE_TYPE_POLYLINE_M:
              esi = new ShapePolyLineM( content );
              break;
            default:
              throw new GisException( "shape type : " + btype + " not recognized! (" + Shape.getEsriTypeDesc( btype ) + ")" );
          }

          // Get a row from the associated DBF file...
          Object[] row = xbase.getRow( fields );
          if ( row != null ) {
            esi.setDbfData( row );
            esi.setDbfMeta( xbase.getFields() );
          }

          shapes.add( esi );
          id++;
        }
      }

      dis.close();
      xbase.close();
    } catch ( IOException e ) {
      throw new GisException( "Error reading shape file", e );

View on GitHub (pinned to f3058517a1)