Error with kml.newpoint

633 views
Skip to first unread message

Anna Grube

unread,
Dec 19, 2012, 5:18:34 AM12/19/12
to simp...@googlegroups.com
Hi,

I am new to py and simplekml and trying to make a scripts which create grid points for a ETA model.

I have this error: AttributeError: 'int' object has no attribute 'count'  and AttributeError     48 ## Saving  ---> 49         kml.save("ETAPoints.kml")

What is wrong here ? 

Thanke in advance

\Anna (Meteorologist)

if __name__ == '__main__':

grid = 0.166
maxlat = 57.5
minlat = 47.5
maxlon = 15.5
minlon = 5.5

## define latitude for points for ETA Domain for EUROPE
latitude = tuple(np.arange(30.00, 70.00, grid))
## define longitude for points for ETA Domain for EUROPE 
longitude = tuple(np.arange(-20.00, 20.00, grid))
## Select the points in the area of interest
#c0 = lat > minlat
#c1 = lat < maxlat
#latitude = lat[c0 & c1]
#c2 = lon > minlon
#c3 = lon < maxlon
#longitude = lon[c2 & c3]

## Made some points 
points = range(len(latitude))
 
    ## open=1 just opens the document in the TOC (table of contents). Not a necessary step.
kml = Kml(name="ETAPoints", open=1) 
## A simple Point
for k in range(len(points)):
      kml.newpoint(name=points[k],
coords=[(longitude[k],latitude[k])])

## Saving
    kml.save("ETAPoints.kml")
print "DONE"



Kyle Lancaster

unread,
Dec 19, 2012, 10:04:20 AM12/19/12
to simp...@googlegroups.com

Hi

I had a quick look at your code  (I did not test it) but it looks like you are giving the name of the point an integer and not a string. Change the one line to this:

kml.newpoint(name=str(points[k]), coords=[(longitude[k],latitude[k]))

Notice the addition of str.

Hope this helps.

Regards

Kyle

--
 
 
 

jmow...@gmail.com

unread,
Jan 23, 2019, 9:10:12 AM1/23/19
to simplekml
Thanks

kendal...@gmail.com

unread,
Dec 24, 2019, 7:09:20 PM12/24/19
to simplekml
This "count" error happens when something is wrong with the name which can't be blank (as one example of an error).

Kyle Lancaster

unread,
Dec 31, 2024, 12:31:01 PM12/31/24
to simplekml
It is a pleasure.
Reply all
Reply to author
Forward
0 new messages