0

I'm learning the basics of shapefile lib for Python, but I've found a problem. After several hours searching I haven't found the cause of this problem.

When I try to create a simple poly:

# -*- coding: utf-8 -*-
import shapefile

cover = shapefile.Writer(coverMask, shapeType=5)
cover.autoBalance = 1
cover.field('name', 'maskTest')
cover.poly([
                      [-3.8525390625, 41.17675781284996,  # W,N
                      -3.515625, 41.17675781284996,  # E,N
                      -3.515625, 41.16577148474995,  # E,S
                      -3.8525390625, 41.16577148474995]])  # W,S

cover.record('mask0')
cover.close()

I obtain as result:

*Traceback (most recent call last):

File "test.py", line 11, in

-3.8525390625, 41.16577148474995]]) # W,S

File "C:\Program Files (x86)\Python37-32\lib\site-packages\shapefile.py", line 1695, in poly

self._shapeparts(parts=polys, shapeType=shapeType)

File "C:\Program Files (x86)\Python37-32\lib\site-packages\shapefile.py", line 1757, in _shapeparts

point = list(point)

TypeError: 'float' object is not iterable*

I'm using Python 3.7.2 and the last version of shapefile lib (I've downloaded it using PIP).

  • 1
    Your ident scheme is incorrect. Please edit the question to specify the line on which the error occurs. – Vince Mar 1 at 12:19
  • Sorry, it's the first time I've posted here. I've just added all the traceback. – Joss Mar 1 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.