I've been hammering at it for ages, but I just can't get pyshp to work. The CSV file looks like this:
lon,lat -122.5163113, 45.55324148 -95.1719409, 29.97979461 153.0072888, -27.45988559 ...
There are many more rows to be had. Using a lot of examples on the internet I've written the below code, but whenever I try to run it I get the error:
Traceback (most recent call last): File "H:/SU5050/shapefile.py", line 1, in <module> import shapefile File "H:/SU5050\shapefile.py", line 14, in <module> w=shapefile.writer(shapefile.POINT) AttributeError: 'module' object has no attribute 'writer'
I've uninstalled and reinstalled pyshp (using pip) and when I try to simply import shapefile it doesn't error out, just when I try to run it.
import shapefile import csv #LON IS X (0) #LAT IS Y (1) file_location = 'H:\SU5050\WORK.csv' out_file = 'H:\SU5050\GPS_Pts.shp' x,y=, with open(file_location,'rb') as csvfile: r=csv.reader(csvfile,delimiter=',') for i,row in enumerate(r): if i>0: x.append(float(row)) y.append(float(row)) w=shapefile.Writer(shapefile.POINT) w.field('x','f',10,8) w.field('y','f',10,8) for j,k in enumerate(x): w.point(k,y[j]) w.record(k,y[j]) w.save(out_file)
Anyone have any idea what I'm doing wrong?