NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist · #3925 most downloaded on Packagist
PHP library to read and write ESRI Shapefiles, compatible with WKT and GeoJSON
Last release 3 years ago
no release in 18 months
Ships unpredictably
gaps range from 1 weeks to 2.6 years
Nearly every release is documented
notes for 23 of 23 stable releases
Nothing withdrawn
no release was ever pulled
10 years old
23 releases · first in 2016
v3 branch will not receive any new features updates anymore. Only eventual bugfixes will be released for this branch. Legacy PHP users can safely keep
v3 branch will not receive any new features updates anymore. Only eventual bugfixes will be released for this branch. Legacy PHP users can safely keep using it, while PHP 8+ users should switch to v4 once it is released.
ShapefileReader::rewind() pointer reset (thank you to Adrian Geissel for finding it)See release notes
ShapefileReader::rewind() pointer resetOne column per quarter.
Full GeoJSON Feature support with properties data
Shapefile::OPTION_IGNORE_FILE_DBFShapefile::OPTION_IGNORE_FILE_SHXShapefileReader::getTotRecords() output constant:
Shapefile::UNKNOWNShapefile::ERR_INPUT_RANDOM_ACCESS_UNAVAILABLESee release notes
Bug in ShapefileWriter::packPoint() method affecting Z and M geometries
Removed duplicated doc block header from ShapefileWriter.php file
Prevented a PHP warning when encoding a boolean false value for a Shapefile::DBF_TYPE_LOGICAL field
false value for a Shapefile::DBF_TYPE_LOGICAL fieldSee release notes
Shapefile\Geometry\Linestring public methods:
Shapefile\Geometry\Linestring public methods:
Shapefile\Geometry\Linestring::isClockwise()Shapefile\Geometry\Linestring::forceClockwise()Shapefile\Geometry\Linestring::forceCounterClockwise()Shapefile\Geometry\Linestring::forceClosedRing()Shapefile\Geometry\Polygon public methods:
Shapefile\Geometry\Polygon::isClockwise()Shapefile\Geometry\Polygon::isCounterClockwise()Shapefile\Geometry\Polygon::forceClockwise()Shapefile\Geometry\Polygon::forceCounterClockwise()Shapefile\Geometry\Polygon::forceClosedRings()Shapefile\Geometry\MultiPolygon public methods:
Shapefile\Geometry\MultiPolygon::isClockwise()Shapefile\Geometry\MultiPolygon::isCounterClockwise()Shapefile\Geometry\MultiPolygon::forceClockwise()Shapefile\Geometry\MultiPolygon::forceCounterClockwise()Shapefile\Geometry\MultiPolygon::forceClosedRings()Shapefile\Geometry\GeometryCollection::reverseGeometries() protected method.Shapefile\Geometry\Polygon and Shapefile\Geometry\MultiPolygon optional constructor parameter $force_orientation.Shapefile\ShapefileReader constructor options:
Shapefile::OPTION_POLYGON_CLOSED_RINGS_ACTIONShapefile::OPTION_POLYGON_ORIENTATION_READING_AUTOSENSEShapefile::OPTION_POLYGON_OUTPUT_ORIENTATIONShapefile::ACTION_IGNOREShapefile::ACTION_CHECKShapefile::ACTION_FORCEShapefile::ORIENTATION_CLOCKWISEShapefile::ORIENTATION_COUNTERCLOCKWISEShapefile::ORIENTATION_UNCHANGEDShapefile::ERR_GEOM_RING_AREA_TOO_SMALLShapefile::ERR_GEOM_RING_NOT_ENOUGH_VERTICESShapefile::UNDEFINEDShapefile\Geometry\Polygon and Shapefile\Geometry\MultiPolygon constructor parameter $flag_enforce_closed_rings is now $closed_rings and accepts Shapefile::ACTION_IGNORE, Shapefile::ACTION_CHECK and Shapefile::ACTION_FORCE values.Shapefile\ShapefileReader constructor options that will disappear in the next releases:
Shapefile::OPTION_ENFORCE_POLYGON_CLOSED_RINGS. Use Shapefile::OPTION_POLYGON_CLOSED_RINGS_ACTION instead.Shapefile::OPTION_INVERT_POLYGONS_ORIENTATION. Use Shapefile::OPTION_POLYGON_OUTPUT_ORIENTATION instead.Shapefile::ERR_GEOM_POLYGON_AREA_TOO_SMALL. Use Shapefile::ERR_GEOM_RING_AREA_TOO_SMALL instead.Shapefile::ERR_GEOM_POLYGON_NOT_VALID. Use Shapefile::ERR_GEOM_POLYGON_WRONG_ORIENTATION instead.See release notes
Shapefile::OPTION_DBF_ALLOW_FIELD_SIZE_255 constructor option for both ShapefileReader and ShapefileWriter classes
Shapefile::OPTION_DBF_ALLOW_FIELD_SIZE_255 constructor option for both ShapefileReader and ShapefileWriter classesSee release notes
Changed GEOJSON_BASETYPE constants for Shapefile\Geometry\Linestring and Shapefile\Geometry\MultiLinestring respectively to 'LineString' and 'MultiLin
GEOJSON_BASETYPE constants for Shapefile\Geometry\Linestring and Shapefile\Geometry\MultiLinestring respectively to 'LineString' and 'MultiLineString' (with a capital S)See release notes
Do not apply Shapefile::OPTION_FORCE_MULTIPART_GEOMETRIES to Point Shapefiles
Shapefile::OPTION_FORCE_MULTIPART_GEOMETRIES to Point ShapefilesSee release notes
Truncate PRJ and CPG files before writing them to prevent content to be appended when Shapefile::OPTION_EXISTING_FILES_MODE is set to Shapefile::MODE_
Shapefile::OPTION_EXISTING_FILES_MODE is set to Shapefile::MODE_APPENDSee release notes
Writing buffer in ShapefileWriter. It allows up to a 50% reduction in writing time
ShapefileWriter. It allows up to a 50% reduction in writing timeShapefileWriter::flushBuffer() methodShapefile::OPTION_BUFFERED_RECORDS constructor option for ShapefileWriter classShapefile::OPTION_EXISTING_FILES_MODE constructor option for ShapefileWriter classShapefile::MODE_PRESERVE, Shapefile::MODE_APPEND, Shapefile::MODE_OVERWRITE constantsisZ(), isM() and getFieldsNames() methods for both ShapefileReader and ShapefileWriter classesShapefileWriter exposes getShapeType(), getBoundingBox(), getPRJ(), getCharset(), setCharset(), getFieldsNames(), getField(), getFieldType(), getFieldSize(), getFieldDecimals(), getFields() and getTotRecords() public methods like ShapefileReaderGeometryCollection::getBoundingBox() method for better performanceShapefileWriter::encodeFieldValue() method for better performance, relying on PHP number_format() for non-textual numeric inputShapefileWriter field-adding methodsShapefile::ERR_DBF_FIELD_NAME_NOT_VALID error type is now defined as "Too many field names conflicting"c+b file access mode for ShapefileWriter classGeometry data when Shapefile::OPTION_DBF_FORCE_ALL_CAPS is enabledShapefile::OPTION_DBF_FORCE_ALL_CAPS optionShapefile::ERR_GEOM_MISSING_FIELD exception was erroneously raised when a field had an explicit null value and Shapefile::OPTION_ENFORCE_GEOMETRY_DATA_STRUCTURE was enabledfread() and fwrite() calls: a ShapefileException is thrown anywaysShapefile::ERR_GEOM_MISSING_FIELD is raised1, not from 0)ShapefileWriter destructor when no record has been written yet$flag_sanitize_name parameter from all field-adding methodsShapefile::OPTION_OVERWRITE_EXISTING_FILES constructor option for ShapefileWriter classShapefile::ERR_DBF_FIELD_NAME_NOT_UNIQUE error typeA *Declaration of X must be compatible with Y* PHP7 Warning thrown for Polygon and MultiPolygon addGeometry protected methods
Polygon and MultiPolygon addGeometry protected methodsA typo in a variable name introduced with a late *code clean-up before final release* that was causing a PHP Notice when reading Shapefiles with *Memo
Shapefile\Geometry namespace with Point, MultiPoint, Linestring, MultiLinestring, Polygon and MultiPolygon classes
Shapefile\Geometry namespace with Point, MultiPoint, Linestring, MultiLinestring, Polygon and MultiPolygon classesShapefileReader and ShapefileWriter classesShapefile, Geometry and GeometryCollection abstract classesnull values in DBF filesMEMO fields)ShapefileException::getDetails() methodShapefile::OPTION_CPG_ENABLE_FOR_DEFAULT_CHARSETShapefile::OPTION_DBF_CONVERT_TO_UTF8Shapefile::OPTION_DBF_FORCE_ALL_CAPSShapefile::OPTION_DBF_IGNORED_FIELDSShapefile::OPTION_DBF_NULL_PADDING_CHARShapefile::OPTION_DBF_NULLIFY_INVALID_DATESShapefile::OPTION_DBF_RETURN_DATES_AS_OBJECTSShapefile::OPTION_DELETE_EMPTY_FILESShapefile::OPTION_ENFORCE_GEOMETRY_DATA_STRUCTUREShapefile::OPTION_ENFORCE_POLYGON_CLOSED_RINGSShapefile::OPTION_FORCE_MULTIPART_GEOMETRIESShapefile::OPTION_IGNORE_GEOMETRIES_BBOXESShapefile::OPTION_IGNORE_SHAPEFILE_BBOXShapefile::OPTION_INVERT_POLYGONS_ORIENTATIONShapefile::OPTION_OVERWRITE_EXISTING_FILESShapefile::OPTION_SUPPRESS_MShapefile::OPTION_SUPPRESS_ZShapefile::FILE_SHPShapefile::FILE_SHXShapefile::FILE_DBFShapefile::FILE_DBTShapefile::FILE_PRJShapefile::FILE_CPGShapefile::SHAPE_TYPE_NULLShapefile::SHAPE_TYPE_POINTShapefile::SHAPE_TYPE_POLYLINEShapefile::SHAPE_TYPE_POLYGONShapefile::SHAPE_TYPE_MULTIPOINTShapefile::SHAPE_TYPE_POINTZShapefile::SHAPE_TYPE_POLYLINEZShapefile::SHAPE_TYPE_POLYGONZShapefile::SHAPE_TYPE_MULTIPOINTZShapefile::SHAPE_TYPE_POINTMShapefile::SHAPE_TYPE_POLYLINEMShapefile::SHAPE_TYPE_POLYGONMShapefile::SHAPE_TYPE_MULTIPOINTMShapefile::DBF_TYPE_CHARShapefile::DBF_TYPE_DATEShapefile::DBF_TYPE_LOGICALShapefile::DBF_TYPE_MEMOShapefile::DBF_TYPE_NUMERICShapefile::DBF_TYPE_FLOATShapefile::ERR_UNDEFINEDShapefile::ERR_FILE_MISSINGShapefile::ERR_FILE_EXISTSShapefile::ERR_FILE_INVALID_RESOURCEShapefile::ERR_FILE_OPENShapefile::ERR_FILE_READINGShapefile::ERR_FILE_WRITINGShapefile::ERR_SHP_TYPE_NOT_SUPPORTEDShapefile::ERR_SHP_TYPE_NOT_SETShapefile::ERR_SHP_TYPE_ALREADY_SETShapefile::ERR_SHP_GEOMETRY_TYPE_NOT_COMPATIBLEShapefile::ERR_SHP_MISMATCHED_BBOXShapefile::ERR_SHP_FILE_ALREADY_INITIALIZEDShapefile::ERR_SHP_WRONG_RECORD_TYPEShapefile::ERR_DBF_FILE_NOT_VALIDShapefile::ERR_DBF_MISMATCHED_FILEShapefile::ERR_DBF_EOF_REACHEDShapefile::ERR_DBF_MAX_FIELD_COUNT_REACHEDShapefile::ERR_DBF_FIELD_NAME_NOT_UNIQUEShapefile::ERR_DBF_FIELD_NAME_NOT_VALIDShapefile::ERR_DBF_FIELD_TYPE_NOT_VALIDShapefile::ERR_DBF_FIELD_SIZE_NOT_VALIDShapefile::ERR_DBF_FIELD_DECIMALS_NOT_VALIDShapefile::ERR_DBF_CHARSET_CONVERSIONShapefile::ERR_DBT_EOF_REACHEDShapefile::ERR_GEOM_NOT_EMPTYShapefile::ERR_GEOM_COORD_VALUE_NOT_VALIDShapefile::ERR_GEOM_MISMATCHED_DIMENSIONSShapefile::ERR_GEOM_MISMATCHED_BBOXShapefile::ERR_GEOM_MISSING_FIELDShapefile::ERR_GEOM_POINT_NOT_VALIDShapefile::ERR_GEOM_POLYGON_OPEN_RINGShapefile::ERR_GEOM_POLYGON_AREA_TOO_SMALLShapefile::ERR_GEOM_POLYGON_NOT_VALIDShapefile::ERR_INPUT_RECORD_NOT_FOUNDShapefile::ERR_INPUT_FIELD_NOT_FOUNDShapefile::ERR_INPUT_GEOMETRY_TYPE_NOT_VALIDShapefile::ERR_INPUT_GEOMETRY_INDEX_NOT_VALIDShapefile::ERR_INPUT_ARRAY_NOT_VALIDShapefile::ERR_INPUT_WKT_NOT_VALIDShapefile::ERR_INPUT_GEOJSON_NOT_VALIDShapefile::ERR_INPUT_NUMERIC_VALUE_OVERFLOWsrc/ reflects namespaces hierarchyiconv() instead of utf8_encode() for charset conversionShapefileException::getErrorType() method returns one of Shapefile::ERR_* constant valuesShapefileReader::fetchRecord() method replaces ShapefileReader::getRecord() and returns an objectbool) not initialized values (null) detection in DBF filesShapefileReader public methods:
setDefaultGeometryFormat()readRecord()ShapefileReader protected method init()Shapefile constants:
Shapefile::FLAG_SUPPRESS_ZShapefile::FLAG_SUPPRESS_MShapefile::GEOMETRY_ARRAYShapefile::GEOMETRY_WKTShapefile::GEOMETRY_GEOJSON_GEOMETRYShapefile::GEOMETRY_GEOJSON_FEATUREShapefile::GEOMETRY_BOTHShapefile numeric error codesBug in binary reading function causing issues with *DBF* fields size
Reversed the orientation of inner and outer rings in GeoJSON output of Polygons and MultiPolygons, complying to section 3.1.6 of RFC 7946
Fixed *composer.json* file. Since version 2.4.0 the library requires PHP 5.4+
Public method setDefaultGeometryFormat(). It sets the default format for future calls to getRecord() and use with the Iterator interface (foreach loop
setDefaultGeometryFormat(). It sets the default format for future calls to getRecord() and use with the Iterator interface (foreach loop)GEOMETRY_GEOJSON_GEOMETRY and GEOMETRY_GEOJSON_FEATURE formats for getRecord() methodgetRecord() can be combined using bitwise Or operator |getRecord() method changed to ShapeFile::GEOMETRY_ARRAYGEOMETRY_BOTH geometry return format for getRecord() method - Please update your code still relying on itProtected method init() allows the main ShapeFile class to be easily extended using a custom constructor
init() allows the main ShapeFile class to be easily extended using a custom constructorCapability to randomly access the shapefile records
getTotRecords(). It provides the number of records in the shapefilesetCurrentRecord(). It sets the current record pointergetCurrentRecord(). It gets the current record pointerPublic method getDBFFields(). It provides the fields definition in the *DBF* file
getDBFFields(). It provides the fields definition in the DBF filePHP 7 Uniform Variable Syntax bugfix in getRecord() method
getRecord() methodNative *DBF* reading capabilities (no dbase functions or external libraries required anymore)
FLAG_SUPPRESS_Z and FLAG_SUPPRESS_M flags for ShapeFile constructorGEOMETRY_BOTH format for getRecord() methodShapeFile namespace and ShapeFileAutoloader class41 and 42Your coding agent can read these notes before it upgrades. Set up the MCP server →