Skip to Content

python_shp

  1. >>> import struct
  2. >>> fichier='testpoly.shp'
  3. >>> f = open(fichier,'rb')
  4. >>> shpread = f.read(100) #lecture des 100 premiers bytes
  5. >>> shptype = struct.unpack('<l',shpread[32:36]) #type de shape
  6. >>> print shptype[0]
  7. 5 # 5 = polygone, voir tableau de correspondance dans Wikipedia
  8. >>> box = struct.unpack('<dddd',shpread[36:68]) # cadre global du shapefile
  9. >>> print box
  10. (-0.009020000000000002, -0.0050160000000000005, 0.0055000000000000014, 0.007392000000000001)