gasparesganga/php-shapefile
Read and write ESRI Shapefiles in PHP with support for common geometry formats. php-shapefile handles SHP/SHX/DBF data, works with WKT and GeoJSON, and includes docs and examples for parsing, editing, and exporting.
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
Shapefile::OPTION_IGNORE_FILE_DBFShapefile::OPTION_IGNORE_FILE_SHXShapefileReader::getTotRecords() output constant:
Shapefile::UNKNOWNShapefile::ERR_INPUT_RANDOM_ACCESS_UNAVAILABLESee release notes
false value for a Shapefile::DBF_TYPE_LOGICAL fieldSee release notes
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 classesSee release notes
GEOJSON_BASETYPE constants for Shapefile\Geometry\Linestring and Shapefile\Geometry\MultiLinestring respectively to 'LineString' and 'MultiLineString' (with a capital S)See release notes
Shapefile::OPTION_FORCE_MULTIPART_GEOMETRIES to Point ShapefilesSee release notes
Shapefile::OPTION_EXISTING_FILES_MODE is set to Shapefile::MODE_APPENDSee release notes
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 expose 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 typeSee release notes
Polygon and MultiPolygon addGeometry protected methods.See release notes
A tiny bugfix release to correct a couple of typos that went unnoticed in v3.0.0.
See release notes
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 codesSee release notes
See release notes
See release notes
See release notes
setDefaultGeometryFormat()getRecord() public methodShapeFile::GEOMETRY_BOTH output formatSee release notes
init() allows the main ShapeFile class to be easily extended using a custom constructorSee release notes
getTotRecords()setCurrentRecord()getCurrentRecord()See release notes
getDBFFields() public method, which provides an array representing the fields definition in the DBF fileSee release notes
See release notes
ShapeFile namespace and ShapeFileAutoloader classFLAG_SUPPRESS_Z and FLAG_SUPPRESS_M flagsGEOMETRY_BOTH format for getRecord() methodSee release notes
getPRJ(). It provides the raw WKT from the .prj file if presentSee release notes
How can I help you explore Laravel packages today?