WEBVTT

00:00:00.000 --> 00:00:01.920 align:middle line:90%
[SQUEAKING]

00:00:01.920 --> 00:00:04.320 align:middle line:90%
[RUSTLING]

00:00:04.320 --> 00:00:05.760 align:middle line:90%
[CLICKING]

00:00:05.760 --> 00:00:09.472 align:middle line:90%


00:00:09.472 --> 00:00:10.680 align:middle line:90%
HELENA VALLICROSA: All right.

00:00:10.680 --> 00:00:12.550 align:middle line:84%
So as I mentioned
in other videos,

00:00:12.550 --> 00:00:14.280 align:middle line:84%
in order to work
with maps, we need

00:00:14.280 --> 00:00:16.980 align:middle line:84%
to make sure that they are
both in the same projection

00:00:16.980 --> 00:00:19.070 align:middle line:90%
to avoid mismatches of the data.

00:00:19.070 --> 00:00:23.550 align:middle line:84%
And to do so, I'm
going to teach you

00:00:23.550 --> 00:00:27.390 align:middle line:84%
how to check on the projection,
how can we extract information

00:00:27.390 --> 00:00:28.200 align:middle line:90%
about them.

00:00:28.200 --> 00:00:32.460 align:middle line:84%
So I'm going to upload a
raster map and a vectorial map.

00:00:32.460 --> 00:00:35.130 align:middle line:84%
The first one is
January temperature

00:00:35.130 --> 00:00:37.180 align:middle line:90%
based on WorldClim maps.

00:00:37.180 --> 00:00:39.420 align:middle line:84%
And the second one is going
to be this vectorial map

00:00:39.420 --> 00:00:41.370 align:middle line:84%
that we already
used also, that is

00:00:41.370 --> 00:00:44.550 align:middle line:84%
the shape of the
surface of the Earth.

00:00:44.550 --> 00:00:46.860 align:middle line:84%
One way to check
information about projection

00:00:46.860 --> 00:00:49.650 align:middle line:90%
is to use the crs.

00:00:49.650 --> 00:00:55.020 align:middle line:84%
Clicking on here, we see
displayed a lot of information

00:00:55.020 --> 00:00:56.580 align:middle line:90%
related to this map.

00:00:56.580 --> 00:01:01.200 align:middle line:84%
But sometimes we only
need this chunk here.

00:01:01.200 --> 00:01:04.680 align:middle line:84%
This is related to
the piece of code

00:01:04.680 --> 00:01:07.280 align:middle line:84%
that R needs to understand
what's the projection we

00:01:07.280 --> 00:01:09.500 align:middle line:90%
are working on.

00:01:09.500 --> 00:01:11.660 align:middle line:84%
So if we want to go
directly on checking these,

00:01:11.660 --> 00:01:13.660 align:middle line:84%
we can just type
projection and the map

00:01:13.660 --> 00:01:14.970 align:middle line:90%
that we want to know about.

00:01:14.970 --> 00:01:17.740 align:middle line:90%


00:01:17.740 --> 00:01:21.980 align:middle line:84%
And here, we have only the
chunk of code related to that.

00:01:21.980 --> 00:01:25.450 align:middle line:84%
We can do the same
with the vectorial map.

00:01:25.450 --> 00:01:28.390 align:middle line:84%
And we see that in
this case, the two maps

00:01:28.390 --> 00:01:29.620 align:middle line:90%
are in the same projection.

00:01:29.620 --> 00:01:32.320 align:middle line:84%
So we can work with
them with no problem.

00:01:32.320 --> 00:01:35.890 align:middle line:90%
Also, as an extra layer of--

00:01:35.890 --> 00:01:37.810 align:middle line:84%
just to double check
they match, I'm

00:01:37.810 --> 00:01:39.580 align:middle line:84%
going to plot them one
on top of the other

00:01:39.580 --> 00:01:42.100 align:middle line:90%
to see that there's actually--

00:01:42.100 --> 00:01:43.870 align:middle line:90%
that they actually fit.

00:01:43.870 --> 00:01:46.030 align:middle line:84%
I'm just going to plot
the map right here.

00:01:46.030 --> 00:01:48.860 align:middle line:84%
And to add the vectorial
map on top of it,

00:01:48.860 --> 00:01:50.810 align:middle line:84%
I just need to add
this part in the code.

00:01:50.810 --> 00:01:55.880 align:middle line:84%
So it means that it's going
to add on top of the previous.

00:01:55.880 --> 00:01:57.920 align:middle line:84%
And here, we have
that the two maps--

00:01:57.920 --> 00:01:58.970 align:middle line:90%
they match.

00:01:58.970 --> 00:02:02.250 align:middle line:84%
So we can work with them
with absolute no problem.

00:02:02.250 --> 00:02:04.460 align:middle line:84%
But in case they wouldn't
be in the same projection

00:02:04.460 --> 00:02:07.070 align:middle line:84%
and we would need to
change one to the other,

00:02:07.070 --> 00:02:12.590 align:middle line:84%
there's this function
right here that it's

00:02:12.590 --> 00:02:20.300 align:middle line:84%
included in the
packages that we've

00:02:20.300 --> 00:02:24.020 align:middle line:84%
been using, that it
transforms the projection

00:02:24.020 --> 00:02:25.460 align:middle line:90%
of vectorial maps.

00:02:25.460 --> 00:02:29.840 align:middle line:84%
So if I'm going to change
from the resolution

00:02:29.840 --> 00:02:33.680 align:middle line:84%
we were using-- the projection
we were using into the Mercator

00:02:33.680 --> 00:02:37.460 align:middle line:84%
projection, and if I
plot this right now,

00:02:37.460 --> 00:02:40.100 align:middle line:84%
you're going to see that
the shape of the map

00:02:40.100 --> 00:02:42.380 align:middle line:90%
is totally different.

00:02:42.380 --> 00:02:45.570 align:middle line:84%
And if we want to change
the projection in a raster,

00:02:45.570 --> 00:02:48.830 align:middle line:84%
we would have to use
another function,

00:02:48.830 --> 00:02:52.560 align:middle line:84%
because this one is not going
to be useful for raster maps.

00:02:52.560 --> 00:02:56.010 align:middle line:84%
Now I'm uploading
information about soils

00:02:56.010 --> 00:02:58.080 align:middle line:90%
that I took from SoilGrids.

00:02:58.080 --> 00:03:01.530 align:middle line:84%
SoilGrid data, it comes
in a different projection

00:03:01.530 --> 00:03:02.860 align:middle line:90%
than WorldClim data.

00:03:02.860 --> 00:03:04.920 align:middle line:84%
So I would need to
transform one to the other

00:03:04.920 --> 00:03:07.710 align:middle line:84%
in order to work with
them at the same time.

00:03:07.710 --> 00:03:13.230 align:middle line:84%
So just to show you how this
data looks like, in this case,

00:03:13.230 --> 00:03:16.310 align:middle line:84%
it's a cationic exchange
capacity of soils.

00:03:16.310 --> 00:03:19.930 align:middle line:84%
So you see the shape is slightly
different than the other map.

00:03:19.930 --> 00:03:23.210 align:middle line:84%
And just to double-check that
it's a different projection,

00:03:23.210 --> 00:03:26.150 align:middle line:84%
we just check on the
information of the map.

00:03:26.150 --> 00:03:29.570 align:middle line:84%
We have here-- on the crs,
we see that the projection

00:03:29.570 --> 00:03:30.920 align:middle line:90%
is different.

00:03:30.920 --> 00:03:36.080 align:middle line:84%
So I am going to reproject
the temperature map

00:03:36.080 --> 00:03:39.260 align:middle line:90%
into the soildata extension.

00:03:39.260 --> 00:03:44.188 align:middle line:84%
And to do that, I'll use
this projectRaster function.

00:03:44.188 --> 00:03:45.980 align:middle line:84%
This might take a little
while because when

00:03:45.980 --> 00:03:49.290 align:middle line:84%
we work with raster maps, we
have a lot of information.

00:03:49.290 --> 00:03:52.460 align:middle line:90%
So it's a very dense grid.

00:03:52.460 --> 00:03:55.010 align:middle line:84%
That makes the
times of processing

00:03:55.010 --> 00:03:58.375 align:middle line:84%
these maps to be a little higher
than possibly a vectorial map.

00:03:58.375 --> 00:04:01.140 align:middle line:90%


00:04:01.140 --> 00:04:07.060 align:middle line:84%
And several minutes later, the
process hopefully worked out.

00:04:07.060 --> 00:04:10.030 align:middle line:84%
I'm just going to plot
to see what we have.

00:04:10.030 --> 00:04:12.540 align:middle line:84%
And here is the
result, where we have

00:04:12.540 --> 00:04:17.070 align:middle line:84%
the temperature map transformed
into the soil projection.

00:04:17.070 --> 00:04:28.810 align:middle line:84%
Just to double-check,
we can always

00:04:28.810 --> 00:04:38.770 align:middle line:84%
see how it went from the
old one to this projection.

00:04:38.770 --> 00:04:43.000 align:middle line:90%