1
00:00:00,030 --> 00:00:06,660
Hi, welcome again and in this lecture I'll
show you how to add another layer to

2
00:00:06,660 --> 00:00:12,929
this map. Currently we have two layers we
have the base map which are map tiles by

3
00:00:12,929 --> 00:00:19,740
map box you can see here and the data
are served by Open Street Map and you

4
00:00:19,740 --> 00:00:24,660
also have your custom layer as well
which is a layer containing circle

5
00:00:24,660 --> 00:00:31,969
markers. So in GIS, geographic information
systems these are referred to as layers.

6
00:00:31,969 --> 00:00:38,809
Now I'd like to add a third layer to my
map and that will be a polygon layer.

7
00:00:38,809 --> 00:00:45,260
So this current layer with markers, this
can be referred to as a point layer.

8
00:00:45,260 --> 00:00:51,690
You also have line layers and polygon
layers so with points, points are better

9
00:00:51,690 --> 00:00:57,739
to represent locations and you have
lines, lines are best for representing

10
00:00:57,739 --> 00:01:04,920
geographical features which resembles
lines such as roads and rivers and then

11
00:01:04,920 --> 00:01:11,659
we have polygons. Polygons are best to
represent areas so for instance in this

12
00:01:11,659 --> 00:01:17,210
lecture what I'll show you is how to add
a layer, a polygon layer that represents

13
00:01:17,210 --> 00:01:25,920
world population by country, so countries
are represented as areas and what we're

14
00:01:25,920 --> 00:01:31,799
going to do is each of the countries
will have a specific color which will

15
00:01:31,799 --> 00:01:37,320
indicate the population of that country
so points for locations lines, for lines,

16
00:01:37,320 --> 00:01:44,720
and polygons for areas. Now of course you
need to have some data to create

17
00:01:44,720 --> 00:01:51,750
a polygon layer. You know just like as we
did with markers we had some data in CSV

18
00:01:51,750 --> 00:01:58,950
in text format and then we used those
data, we opened them with Pandas and then

19
00:01:58,950 --> 00:02:05,189
we iterated through those lines of
data and we added the markers to the map.

20
00:02:05,189 --> 00:02:13,450
Now for polygons the way to add
polygons via Folium is by

21
00:02:13,450 --> 00:02:21,010
using the folium.GeoJson method,
so basically let me make some space here

22
00:02:21,010 --> 00:02:27,780
the way this would work is you want to
add to feature group the variable here.

23
00:02:27,780 --> 00:02:37,360
You want to add a child which will be a
folium.GeoJson object. So this is the

24
00:02:37,360 --> 00:02:46,030
method with brackets here that creates
a GeoJSON object and for GeoJSON data we

25
00:02:46,030 --> 00:02:52,630
will use this world.JSON file. You
can find this attached in this lecture

26
00:02:52,630 --> 00:02:57,340
and let me explain what this is, but
careful, don't open it on Atom

27
00:02:57,340 --> 00:03:05,200
because if your computer is a bit slow
your atom may crash, so try to open

28
00:03:05,200 --> 00:03:12,250
it with a lighter editor such as notepad
for instance, or cat on a Linux terminal

29
00:03:12,250 --> 00:03:20,290
or Mac. Anyway this is the JSON file you
can refer to it as JSON or GeoJson.

30
00:03:20,290 --> 00:03:27,370
Actually GeoJSON is a special case of
JSON. Basically the format is always the

31
00:03:27,370 --> 00:03:34,090
same, it starts with curly brackets and
basically it contains a string which is

32
00:03:34,090 --> 00:03:45,880
like a Python dictionary with keys and
values. Keys, key and value where this

33
00:03:45,880 --> 00:03:52,299
curly bracket ends somewhere here I
believe. If I'm not wrong. This one ends

34
00:03:52,299 --> 00:04:00,130
in here, yeah. Then you have the other key,
geometry. So what is geometry? When the

35
00:04:00,130 --> 00:04:06,250
type of geometry is multi polygon so
basically you have this kind of

36
00:04:06,250 --> 00:04:15,030
attributes that describe the data.
Type multi polygon or coordinates.

37
00:04:18,480 --> 00:04:23,520
So this is now starting to describe the features,
the polygons so these are the

38
00:04:23,520 --> 00:04:27,750
coordinates over the first polygon that
will be displayed on the map. Let's say

39
00:04:27,750 --> 00:04:36,560
this is one specific country and that's
that's, that's Antigua and Barbuda, yeah.

40
00:04:36,560 --> 00:04:43,770
A small country but anyway and these are
the coordinates that will determine the

41
00:04:43,770 --> 00:04:50,010
location of the polygon in your map so
basically Folium will read all this

42
00:04:50,010 --> 00:04:57,720
information and it will decide where to put
the polygons and then you can also use

43
00:04:57,720 --> 00:05:04,920
other attributes of this such as
population which is here, yeah. You will use

44
00:05:04,920 --> 00:05:13,050
this population value to put a color for
that population and so on and so forth.

45
00:05:13,050 --> 00:05:20,280
You have all countries of the world in
this JSON file, so spend a few minutes

46
00:05:20,280 --> 00:05:26,070
looking at this file to understand its
structure and in the next lecture I'll

47
00:05:26,070 --> 00:05:32,570
go ahead and load the JSON file into
Python and display the polygon layer.

48
00:05:32,570 --> 00:05:34,000
See you there!

