1
00:00:02,020 --> 00:00:10,540
Hi again in this video I'm going to show you how to add the elevation values so these ones in here

2
00:00:11,560 --> 00:00:13,950
to the popup window.

3
00:00:13,990 --> 00:00:20,910
Currently, our script simply prints out this string in the pop up window.

4
00:00:21,790 --> 00:00:34,390
So are we going to change and that the way you do that is by first loading the elevation data into a Python

5
00:00:34,390 --> 00:00:36,940
list and then in the loop here

6
00:00:36,970 --> 00:00:50,570
you want to say let's say l in zip(lat, lon, elev) like that here in the pop up argument you

7
00:00:50,640 --> 00:00:53,230
pass the l attribute.

8
00:00:53,290 --> 00:01:03,730
So again we create a list which is named elev, so variable elev, that would be a list of all the elevations

9
00:01:04,150 --> 00:01:09,760
and then we iterate through these three lists.

10
00:01:10,270 --> 00:01:16,930
So lt will get the first item of lat, ln will get the first item of lon, el will get the first

11
00:01:16,930 --> 00:01:22,270
item of elev and those items will be distributed in this function in here.

12
00:01:22,270 --> 00:01:26,790
So lt in here, ln in here, and el in here.

13
00:01:27,100 --> 00:01:35,720
Now I want to save this and execute but I expect to get an error and I want you to see the erro so

14
00:01:35,750 --> 00:01:41,570
that you get familiar with handling errors as well.

15
00:01:41,780 --> 00:01:52,150
So the error is happening on line 14 in this file map1.py which is our file, line 14

16
00:01:52,150 --> 00:01:52,540
is here.

17
00:01:53,590 --> 00:02:03,250
So this is the line and then we have add child pop up. a=As it seems this error has to do with this pop up

18
00:02:04,510 --> 00:02:05,590
object.

19
00:02:05,640 --> 00:02:09,140
I would say this is not a very good error message actually.

20
00:02:09,280 --> 00:02:11,950
It's hard to to read this error and troubleshoot it.

21
00:02:13,060 --> 00:02:16,300
So not very good information given by Folium here.

22
00:02:16,540 --> 00:02:18,550
But anyway uh we have some clues.

23
00:02:18,610 --> 00:02:28,710
So pop up and this says name child get name attribute error numpy.float64 object has no

24
00:02:28,710 --> 00:02:37,140
attribute get_name, so it seems that Folium is trying to apply the get name method

25
00:02:37,630 --> 00:02:43,540
which is a method inside the Folium code base and it's trying to apply it to a number.

26
00:02:43,540 --> 00:02:58,170
So I think that this l here is actually a number and I can check that by saying print type el, save.

27
00:02:58,360 --> 00:03:02,310
Execute the script.

28
00:03:02,560 --> 00:03:03,700
Here is the type.

29
00:03:04,300 --> 00:03:06,200
So this is numpy float 64.

30
00:03:06,230 --> 00:03:11,620
So basically is a float type.

31
00:03:11,660 --> 00:03:14,990
It's actually a special float of the Numpy library, so it's a number.

32
00:03:15,170 --> 00:03:22,580
But anyway you can call it a float so it's a number it's not a string but if you look at help, sorry.

33
00:03:23,360 --> 00:03:29,690
Help(folium.Marker)

34
00:03:30,320 --> 00:03:38,760
you'll see that the pop up parameter expects a string from you as input but you're passing instead you're

35
00:03:38,750 --> 00:03:42,260
passing a float number so you don't want to do that.

36
00:03:42,320 --> 00:03:47,660
What you want to do is to simply convert that float number to a string.

37
00:03:57,150 --> 00:03:59,650
Save the script, go to the terminal,

38
00:04:02,690 --> 00:04:06,520
execute again.

39
00:04:06,560 --> 00:04:09,620
Go to Firefox, reload,

40
00:04:12,790 --> 00:04:18,670
and you get the elevation displayed correctly.

41
00:04:20,990 --> 00:04:22,110
Yeah that's about it.

42
00:04:25,790 --> 00:04:28,270
You can also...

43
00:04:28,400 --> 00:04:38,090
You may also want to stylize what you're displaying, so to add more information there such as

44
00:04:38,720 --> 00:04:39,590
" m" for meters.

45
00:04:43,100 --> 00:04:46,790
So I'm adding the m string to every

46
00:04:49,430 --> 00:04:52,930
pop up window information for all the elevation numbers.

47
00:04:53,030 --> 00:05:00,110
So we're talking about 2447.0 meters, that's elevation of the

48
00:05:00,110 --> 00:05:00,590
volcano.

49
00:05:01,160 --> 00:05:01,600
Yeah.

50
00:05:01,610 --> 00:05:02,330
That is the idea.

51
00:05:04,010 --> 00:05:06,980
I hope this was clear and I'll talk to you later.

