Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create shapefile from csv data using but i am constantly getting this error,

Traceback (most recent call last):
  File "", line 31, in <module>    
  File "/usr/lib/python2.7/dist-packages/", line 862, in save
  File "/usr/lib/python2.7/dist-packages/", line 829, in saveShp
    self.__shapefileHeader(self.shp, headerType='shp')
  File "/usr/lib/python2.7/dist-packages/", line 586, in __shapefileHeader
    raise ShapefileException("Failed to write shapefile bounding box. Floats required.")
shapefile.ShapefileException: Failed to write shapefile bounding box. Floats required.

For some reason it is not saving the shapefile properly, it is able to create .shp file but that's it. There are no .dbf or .shx. I believe i am making some mistake somewhere in the code, but not sure where. Here is my code.

import csv
import shapefile
import BIL

File_loc = raw_input("Enter the file name and folder location: ")

w = shapefile.Writer(shapefile.POINT)

with open('treeMap.csv', 'rb') as f:
    reader = csv.reader(f)
    for rec in reader:
        lat=[float(i) for i in lat];lon=[float(i) for i in lon]
        w.record(rec[2], rec[3], MAT[0], TSD[0], AnnTMin[0], ANNPREC[0], rec[5], rec[6])    

print "Shapefile Successfully created"    
share|improve this question
up vote 6 down vote accepted

You need to make some explicit float casts when creating the point:

        w.point(float(rec[6]), float(rec[5]))
share|improve this answer
That worked like a charm thanks @Mike – Sam007 Jun 21 '12 at 16:01

Shapefile field names must be not exceed 10 characters in length. Also, shouldn't you define each field data type? I'm not sure what the default type is. You can also step-into to view the variables during execution. I recommend PyScripter.

share|improve this answer
+1 for suggesting PyScripter – mapoholic Jun 21 '12 at 6:35
Actually the handles the truncating automatically so we do not need to worry about that. Is PyScripter not there for Linux? I was not able to find it on my Synaptic or Ubuntu Software Center. – Sam007 Jun 21 '12 at 16:11
Seems PyScripter is windows only. Eric IDE is very powerful and supports Ubuntu/Linux. Current version is Eric5. – klewis Jun 22 '12 at 15:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.