SHP
application/x-shapefile
Magic Bytes
Offset: 0
00 00 27 0A
The Shapefile (SHP) is a geospatial vector data format developed and maintained by Esri for interoperability among geographic information system software. It serves as an industry standard for storing the geometric location and attribute information of geographic features such as points, lines, and polygons. Although technically a legacy format replaced by more modern geodatabases, it remains widely used in cartography and spatial analysis due to its broad compatibility across mapping applications.
Validation Code
How to validate .shp files in Python
Python
def is_shp(file_path: str) -> bool:
"""Check if file is a valid SHP by magic bytes."""
signature = bytes([0x00, 0x00, 0x27, 0x0A])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .shp files in Node.js
Node.js
function isSHP(buffer: Buffer): boolean {
const signature = Buffer.from([0x00, 0x00, 0x27, 0x0A]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsSHP(data []byte) bool {
signature := []byte{0x00, 0x00, 0x27, 0x0A}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/shp
curl https://filesignature.org/api/v1/shp