 Hello. My name is Stacy. I'm a GIS analyst with the Natural Capital Project, and I'm glad that you've joined me to learn some techniques for working with the geospatial data that's used by the Invest Ecosystem Service Modeling Toolkit. A reminder that this series is not an introduction to GIS in general, nor does it provide an introduction to any specific GIS software. But it does cover specific topics that are useful for working with Invest models. This episode provides an overview of coordinate systems. To get the most out of this tutorial, I highly recommend following along in your own GIS session. In this video, we will demonstrate techniques in QGIS, and we'll be working with some sample data. The webpage for this video provides a link to the sample data that we'll be using. So if you haven't already, now is a good time to pause the video, download the sample data, unzip it, and bring up a QGIS session before continuing. A coordinate system defines how the locations on a two-dimensional digital map are related to actual locations on the Earth. There are two types of coordinate systems, geographic and projected. Geographic coordinate systems define distances with angular units of degrees. Projected coordinate systems define distances with linear units, usually meters. Most Invest models require that all of your inputs have exactly the same projected coordinate system, where the linear units are in meters. One exception is coastal vulnerability, which requires that your area of interest have a projected coordinate system, but the other inputs may have a geographic coordinate system. As always, it's important to read the user guide to learn about the data requirements for each model. In this video, we will cover, first of all, how to identify the coordinate system that is used by your data, how to re-project your layers to a common projected coordinate system, and how to verify that all of your layers have exactly the same projected coordinate system. And we will also learn how to troubleshoot a couple of common invest errors that are related to coordinate systems. And in order to prepare your data for use and invest, it is important to know which projected coordinate system is needed for your study area. Now this is mostly your decision, since Invest supports a wide variety of coordinate systems via the GDAL Python library. However, from time to time, we might try to use a coordinate system that is not well supported by GDAL, and in that case, we'll need to choose a different one. We will not cover the pros and the cons of different types of coordinate systems in this tutorial. You can find that information easily with a web search. But a good default is to find out which UTM zone your study area is in, and use that UTM coordinate system for all of your input layers. Now there are times where you are required to, or you prefer to, use some other specific projection that is not UTM, and that's totally fine, as long as it's supported by GDAL. For this tutorial, we will use UTM since it is widely applicable. Now the next thing you need to know is which coordinate systems your raw data layers start out with. Now it's likely that most, or probably all, of the spatial data that you collect from out in the world will be in a coordinate system that is not the same as the one that you want to use for your analysis. So as an example, let's start looking at our sample data in a GIS. If you are using the QGIS session that you saved from the previous tutorial, you'll already have the data that we'll be using. So just hang out for a minute. If you're joining us for the first time, open an operating system window to the folder where you unzip the sample data. And this folder should be called coordinate system data QGIS. So we'll look at the file called LULCEsaNapal.tiv. This is land use and land cover data from the European Space Agency, which is a very commonly used global data set. Land use and land cover data is required by many different invest models. So it's important to get used to working with it. The original data set is over two gigabytes in size, and it is in net CDF format. So to make it easier to use for this tutorial, I have clipped out a smaller subset for our area in Nepal and saved it as TIF format. Other raster formats are also supported by invest, but I highly recommend using TIF because it is a very standard format that's easy to work with. The easiest way to bring this layer into QGIS is to drag and drop the TIF file. In my version of QGIS by default, the layer will be shown with a color scale of black to white based on the numeric land use codes that we see in the legend. Now your version might be different. In the first video, we covered symbolizing this land cover raster. So we won't cover that again here. But you should note that the color schemes in your GIS may also be different than mine. And that's okay. To see which coordinate system this layer comes with, right click on the land cover layer and select properties. Then click on the information tab. The coordinate system is shown on the line labeled CRS, which stands for coordinate reference system. And the coordinate system is WGS84 geographic. Another thing we see is that for units, we have degrees. Now WGS is a very common geographic coordinate system. We can tell that it's a geographic coordinate system because the CRS specifically says geographic and the units are in degrees. So go down further and look at the pixel size. We see that it has a very small value of .0027. And this is a measure of degrees. Seeing a cell size like that is a good indication that you are working with a geographic coordinate system, not a projected coordinate system. With a projected coordinate system, we have linear units, typically in meters. If the cell size was .0027 meters, that would be extremely high resolution. So just from looking at the cell size, we can tell that we're working with degrees. Okay, we can click the cancel button to close this window. In QGIS, the tool that is used to change the coordinate system of our raster is called warp. You can read it under the raster toolbox. Go down to projections and then down to warp. Now note that there is also a tool here called assign projection. It's important to remember that assign projection is not the same as reprojecting. And the assign projection tool should not be used for this purpose. The assign projection tool does not translate one coordinate system to another, and that's what we need to do. Instead, it simply overwrites the layers metadata with new coordinate system information. And this can cause a lot of problems when trying to use it in both the GIS and it invest. So let's double click on the warp tool to open it up. The next input is the raster layer itself. And if you, if your session is like mine, you will have it automatically populated with LULC, ESA, Nepal, or you can click on the dropdown to select it. The next input is source CRS. And this is shown as optional, because by default, the tool will detect the input coordinate system of WGS 84 automatically. So we can leave that blank. The next input is target CRS. And this is also shown as optional, but we do need to choose one. So let's click the icon to the right of the dropdown menu. And by default, everything in this window is grayed out. And we have a checkbox next to this entry for no CRS. So we need to uncheck this. And when we do that, all of our options will become active. And we can see down here under coordinate reference system that we have a lot of options to choose from. So what I think is the easiest thing to do in QGIS is to go up to this filter box at the top of the window and type in some of the name of the projection we want to use. So in this case, let's type in UTM zone 45N. This is for UTM zone 45N, which is the correct UTM zone for our sample data, which is in Nepal. And when we do that in the filter box, we'll see a list of options be created in this coordinate reference system list. What you want to use is at the bottom called WGS84 UTM zone 45N. And we can see in this map, it shows you exactly where that is in the world. So that's really nice. All right, once we've selected UTM zone 45N, we can click OK. And we'll see that the target CRS is populated. The next option is choosing which resampling method to use. And by default, this is set to nearest neighbor, which performs a nearest neighbor analysis to assign values to the reprojected raster. Now for categorical data like the land cover map, nearest neighbor is the technique that should be used. To resampling continuous data, you may want to consider other resampling techniques. In particular, when resampling a digital elevation model or DEM, we should always use bilinear or cubic, never nearest neighbor. Because if we use nearest neighbor instead of bilinear or cubic, then we'll end up with all sorts of strange things when we create the hydrology layers of flow accumulation, flow direction, etc. All right, so it is important to consider which resampling method you use. And for our land cover raster, we will keep the default of nearest neighbor. Next, we can select a no data value for the output raster. By default, the warp tool assigns the same no data value that is used by the input layer. To use rasters and invest, it is important to have a no data value set. If one is not assigned, you'll run into some odd errors that are hard to troubleshoot. So let's see if there is a no data value set in our input raster. Back in our layers window. Let's right click on the layer. Oh, you will see ESA Nepal. And go to properties. And then the information tab. If we scroll down to where it says bands. You will see that there's one band to this raster. And the no data value is set to zero. So this is good. The no data value is set to zero. If there was no value here, then we would want to assign a no data value for this raster. Okay, but we don't need to so we can click cancel. So now back in the work tool for the no data data value, we can leave the default as not set. Okay, because then it will use the value that is already in that layer, which is a value of zero. Next we'll choose the output file resolution. This is the cell size for the output layer. And the ESA land cover website says that the resolution of this data is 300 meters. And personally, I prefer to work with round numbers like 300. Since it's easier for me to visualize this, and it's easier for me to compare with other raster layer resolutions. So we will use a value of 300. Of course, you can choose other cell sizes if you want. In particular, sometimes it's useful to choose a smaller cell size that is the same as some other data layer that you'll be using in your modeling. Now what I don't generally recommend is choosing a larger cell size than what the original data comes in, since that would cause you to lose information. In this case, we will type in 300 for the output file resolution. Now we don't need to use any of the advanced parameters. So we can scroll down past there. And we can go to the entry that says reprojected. Here's where you choose the output file that you want to be written with the new coordinate system information. So we'll click the icon to the right and say save to file. So for this, we will migrate to wherever it is that you are saving your output for these tutorials. I'm going to save it in the sample data folder. And the sample data folder is called coordinate system data QGIS. And in here, I'm going to name the file LULC underscore ESA underscore Nepal underscore UTM.TIF. LULC ESA Nepal underscore UTM.TIF. Now of course you can name this anything you want to. Right, so we'll click save. Right now we have everything filled in and we can click the run button. We should finish pretty quickly. And we close this window, we'll see that this projected layer is now in your layers menu. Now if we click on and off this new projected raster. It will appear that this new raster that's projected in UTM is in the same place with and overlaps with the original data that's in WGS 84, but they actually have different coordinate systems. So this is a good time to point out the QGIS does what's called on the fly reprojection, which means that it will try to make all of your layers visually overlap by reprojecting them to a common coordinate system behind the scenes. This is done just for visualization. And the rasters do retain their individual coordinate systems that you have set. Basically, this on the fly reprojection is helpful, but it can also hide the fact that your layers do have different coordinate systems. So it's easy to think that just because several layers appear to line in QGIS that they actually align based on their coordinate systems. But if they do not have the same coordinate system, they may not actually align. If you use these layers and invest, they will give you an error. So be sure to check the coordinate system of all of your layers, and don't just assume that just because they look like they overlap in the GIS that they all do have the same coordinate system. So let's check the coordinate system of this new layer, right click on the new layer and select properties. Now we see that the coordinate reference system is in UTM zone 45 North, and it says projected. We also see that the unit is in meters. And if we scroll down, we see that the pixel size is 300 by 300. All right, all of that looks good. So let's click cancel to close this window. As we saw in the warp tool, there are a lot of coordinate systems available, and some look very similar. So getting them exactly the same for all of your spatial inputs can be very challenging. To make this easier, we can use a layer that we already have projected into the correct coordinate system to define the coordinate system for other layers that we're working on. Now, first, we'll add a new spatial layer to our map from your sample data folder. Let's add erosivity underscore Nepal dot tip. Let's add that to our QGIS session. Erosivity underscore Nepal dot tip is a climate layer that is used in the sediment model specifically. And we won't talk about it here, but we'll just use it for demonstration purposes. So let's right click on the erosivity layer, select properties, and then information again. Once again, we see that the CRS is set to WGS 1984 geographic. So we will need to project this to UTM to match our other land cover layer if we are going to use this for invest modeling. So let's click cancel. Now once again, we'll need to use the warp tool. So let's click on raster and projections and open up the work tool again. This time our input layer is going to be erosivity underscore Nepal for the source CRS. Once again, this is optional because the tool will automatically detect the reference the coordinate reference system so we don't need to add that. Now for target CRS. Now that we have our land cover map projected in the coordinate system we want to use, we can use it to set the target CRS for the erosivity layer. So what we can do is just select LULC ESA Nepal UTM into the target CRS window. And when we drag it in there, it will automatically detect the UTM zone 45 North that's being used for our projected LULC layer. And this makes it so much easier to use exactly the same projected coordinate system for all of your layers, and I do highly recommend using this feature. The next option is resampling method, and we will leave that at nearest neighbor. And again, we will leave the no data value, not set for output file resolution. So just earlier, I prefer to use round numbers for cell size. And in this case, the erosivity data is based on climate data that I know has a resolution of one kilometer. So for this, we're going to type in a value of 1000 so that the erosivity layer can also have a resolution of one kilometer. So we don't need any of the advanced parameters. So we can go down to the reprojected input. And let's click on the box to the right and say save to file. Once again, I'm going to save this data in the same sample data folder. And I'm going to call it erosivity underscore Nepal underscore UTM dot TIF. Right. And again, you can call it anything you want to but I will call it erosivity Nepal UTM dot tip. All right, let's click run. And that should go very quickly and click close. And once again, let's check the coordinate system of this new layer. Right click on the new layer and select properties, then information. And we can see that the CRS is now UTM zone 45 North, and it's a projected coordinate system. The units are in meters. And the pixel size is 1000 by 1000. So again, all of this looks great. So we can click cancel to close this window. Now when you're creating data to go into invest, you will go through this process for each spatial layer, both rasters and vectors, making sure that they all have the same projected coordinate system. And if they do not all have the same projected coordinate system, then invest will give an error. So let's look at a couple of the typical errors that we see, and look at how we fix them. All right now invest is pretty smart, and it tries to catch data errors when you enter inputs into the user interface. If you enter a layer that is in a geographic coordinate system when it needs to be in a projected coordinate system. You will see a red X next to the input, and you'll see a red X next to run. If you click on the X, you will see the message that the data set must be projected in linear units. This means that you need to go back to the GIS and re project this layer or warp this layer to a projected coordinate system. Another error that's common is if you enter layers that need to have the same coordinate system but don't. This time, you will see red X is next to multiple inputs, as well as the run button. If you click on the X, you'll see the error. Bounding boxes do not intersect, and you'll have this whole list of numbers. This means that invest compared the spatial extents and spatial extents are also called bounding boxes. It compared the spatial extents of the input layers and found that they do not overlap. Usually, this is caused by being in different coordinate systems. This is a problem for invest. When this happens, we need to go back to the GIS, look closely at the coordinate system of each layer, find the one or the ones that are not in the projection that you want to use for your project, and re-project them to match the others. You can also use the error message that you see in this window to maybe identify which layer it is that has different coordinates than the ones that you intend to use. Okay, that's enough for this session. You might want to save your QGIS session so that you can keep using it for later episodes. If you have any questions or comments about this episode, we'd love to hear from you on our community forum. There's a link to the forum in this video's webpage, where you can search for previous posts and create a new post under the category of training. I and other techies at NACAP will see your post and will respond as soon as we can. Thanks for watching and see you next time.