{"record":{"id":"936ff9220ad79248","repo":"pentaho/pentaho-kettle","slug":"shape-type-btype-not-recognized-typedesc","errorCode":null,"errorMessage":"shape type : ${btype} not recognized! (${typeDesc})","messagePattern":"shape type : (.+?) not recognized! \\((.+?)\\)","errorType":"exception","errorClass":"GisException","httpStatus":null,"severity":"error","filePath":"plugins/shapefilereader/core/src/main/java/org/pentaho/gis/shapefiles/ShapeFile.java","lineNumber":140,"sourceCode":"\n          switch ( btype ) {\n            case Shape.SHAPE_TYPE_NULL:\n              esi = new ShapeNull( content );\n              break;\n            case Shape.SHAPE_TYPE_POINT:\n              esi = new ShapePoint( content );\n              break;\n            case Shape.SHAPE_TYPE_POLYLINE:\n              esi = new ShapePolyLine( content );\n              break;\n            case Shape.SHAPE_TYPE_POLYGON:\n              esi = new ShapePolygon( content );\n              break;\n            case Shape.SHAPE_TYPE_POLYLINE_M:\n              esi = new ShapePolyLineM( content );\n              break;\n            default:\n              throw new GisException( \"shape type : \" + btype + \" not recognized! (\" + Shape.getEsriTypeDesc( btype ) + \")\" );\n          }\n\n          // Get a row from the associated DBF file...\n          Object[] row = xbase.getRow( fields );\n          if ( row != null ) {\n            esi.setDbfData( row );\n            esi.setDbfMeta( xbase.getFields() );\n          }\n\n          shapes.add( esi );\n          id++;\n        }\n      }\n\n      dis.close();\n      xbase.close();\n    } catch ( IOException e ) {\n      throw new GisException( \"Error reading shape file\", e );","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/shapefilereader/core/src/main/java/org/pentaho/gis/shapefiles/ShapeFile.java#L122-L158","documentation":"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).","triggerScenarios":"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.","commonSituations":"Processing 3D/measure shapefiles (Z/M types), MultiPoint or MultiPatch exports from CAD/GIS tools, or files whose type field is corrupt.","solutions":["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).","Use a different, more complete shapefile library (GeoTools, GDAL) for unsupported types.","Extend ShapeFile.readFile with a case constructing the appropriate Shape subclass.","Skip or quarantine records with unrecognized type codes before parsing."],"exampleFix":"// before\nogr2ogr -f \"ESRI Shapefile\" out.shp in3d.shp   // keeps Z type 15\n// after\nogr2ogr -f \"ESRI Shapefile\" -nlt POLYGON out.shp in3d.shp   // downgrades to type 5","handlingStrategy":"validation","validationCode":"byte[] header = new byte[100];\ntry ( RandomAccessFile raf = new RandomAccessFile( shp, \"r\" ) ) { raf.readFully( header ); }\nint type = ByteBuffer.wrap( header ).order( ByteOrder.LITTLE_ENDIAN ).getInt( 32 );\nSet<Integer> supported = Set.of( 1, 3, 4, 5, 13 ); // match ShapeFile's switch\nif ( !supported.contains( type ) ) throw new IllegalStateException( \"Unsupported shape type code \" + type );","typeGuard":null,"tryCatchPattern":"try {\n  shapeFile.readFile();\n} catch ( GisException e ) {\n  log.error( \"Shape type unsupported or file unreadable: \" + e.getMessage(), e );\n}","preventionTips":["Check the shape type code in the .shp main header (byte offset 32) before processing.","Convert Z/M/MultiPoint/MultiPatch files to supported types with ogr2ogr -nlt.","Prefer a full-featured library (GDAL/GeoTools) for exotic shapefiles."],"tags":["shapefile","gis","geometry","parsing"],"backgroundTag":"unsupported-enum-value","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}