 Hello, I'm Stacy. I'm a GIS analyst with a natural capital project, and I'm glad that you've joined me to learn some techniques for working with the geospatial data that is used by the Invest Ecosystem Services Modeling Toolkit. This episode provides an introduction to working with vector layers. 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 ArcGIS, and we'll be working with some sample data. The webpage for this video provides a link to the sample data that we will be using. So if you haven't already, now is a good time to pause this video, download the sample data, unzip it, and bring up an ArcGIS session before continuing. Most of the data that is used by Invest Models are rasters, but most models also have vector data as either required or optional input. A vector layer may contain either points, lines, or polygons. The Coastal Vulnerability Model provides a good example of all of these. Wind and wave data is given as a point vector. The continental shelf is defined as a line vector, and habitats are defined as polygons. Here are some examples of vector layers that are used as inputs to different Invest Models. The ones with an asterisk next to them, like geomorphology or watersheds, also require additional parameters for each feature, which we must define in the vector data's attribute table. Now, as usual, I recommend consulting the Invest User Guide to learn the specific requirements for whichever model it is that you're working with. Something else to know about vectors is that there are two primary formats that they can come in, Shapefile and GeoPackage. Shapefiles were developed by Esri many years ago and have historically been the most common way of defining vector data. Now, I use Shapefiles all the time, and you'll find Shapefiles in many of our model sample data sets. However, Shapefiles have a lot of limitations, just a few of which I've listed here. First, Shapefiles are defined by at least four different separate files. Each of them has a different file type, and all of these files are required for the Shapefile to work properly. Shapefiles have a file size limit of two gigabytes, and their attribute table field names are limited to only 10 characters. Now, if you work extensively with vector attribute data, you know how frustrating that limitation can be. GeoPackages are a modern, open, platform-independent data format that is becoming widely used. GeoPackages consist of only a single file. They have no limit on their file size, and you can use much longer, more descriptive field names. The downside is that ArcGIS support for GeoPackages is still somewhat limited. They are much better supported in QGIS, but we are working with ArcGIS right now. Now, there are other differences between these two formats, which you can learn about with the web search. NATCAP has been increasingly supporting GeoPackages as both inputs and outputs of our models, and we encourage you to try using GeoPackages if you haven't already. Now, let's go look at an example of both of these formats in ArcGIS. Open a file explorer window to the sample data that you downloaded for this tutorial. In the folder called Vector Basics Data, you'll see two different versions of the same data. One data set is called BuildingsOSMGeoPackage.gpkg, which is vector data of building footprints from the OpenStreetMap project, which is in GeoPackage format. These other four files, called BuildingsOSMShapeFile, are the same OpenStreetMap building data in shapefile format. Now, all of these files together are required to make up a single vector layer. Let's bring both of these layers into the GIS. We can drag and drop shapefiles into the GIS using the file that ends in .shp. So let's drag BuildingsOSMShapeFile.shp into our GIS session. However, we can't simply drag and drop the GeoPackage file into ArcGIS. So we need to go to Add Data and navigate to our sample data folder, Vector Basics Data. Once we go in this folder, we'll double-click on the file called BuildingsOSMGeoPackage. And inside of there, we'll select the layer MainBuildingsOSMGeoPackage and click Add. We can see that these layers contain the same polygons. If we turn things on and off, we can see that the polygons are exactly the same. If we right-click and open the attribute table for each of these layers, we also see that the fields are the same between them. And we can work with these fields in a similar way, whether we're working with GeoPackages or Shapefiles. Now, because ArcGIS currently has limited support for GeoPackages, and many of us are still using Shapefiles, we will work with Shapefiles for the rest of this tutorial. Most of the same methods will also apply to GeoPackages. Now this vector layer contains polygons of building footprints that can be used as input to the Urban Flood Mitigation Model for calculating infrastructure damage due to flooding. I downloaded these data from OpenStreetMap, clipped them to our study area, and projected them to the coordinate system used by some of the other sample data provided for this model. To learn more about coordinate systems, please check our previous tutorial that covers that topic. All right, now we have our basic data set to work with. So let's look at the user guide to see what the requirements are for this layer. The webpage for this tutorial includes a link to the Urban Flood Risk Mitigation Model chapter, which you can open now. Under the data needs section of this chapter, there's an entry for built infrastructure vector. Now this is an optional layer. If we read this entry, we learn that the vectors attribute table must contain a column called type with integer values that reference the building type. Okay, for example, a value of one corresponds with residential, a value of two corresponds with office, etc. It also says that this type field corresponds with a column that is also called type in the damage loss table, which is the next entry in the user guide. Now going back to the GIS, let's look at the shapefile attribute table. Now if we look at all of the column entries, we see that there is not a type field, so we need to add one. To do this, click on the table options in the upper left hand corner, and go to the add field tool. First, we'll type in the field name, which is just type. And I'll note here that the exact spelling is critical, or else the model will give an error. Since we will only be working with one building type for this example, we can keep the default field type of short integer. Now click OK. We can see that the column has been added. And by default, all of the values are filled in with zeros. So we'll need to assign a building type to each polygon. Now to keep it simple for this exercise, let's just say that they are all residential buildings, and we will assign a value of one to represent residential buildings. Now since there are almost 7000 polygons, thankfully ArcGIS makes it easy to assign a value of one to all of them. Now for a real world project, you might need to assign different type values to different polygons. And there are several ways to do this, which I won't get into in much detail here. But one way is to select the set of polygons like this, just select them using shift click or control click. Another way is to use the select by attributes function, which you can see here under the table functions. And this lets you build a SQL query expression to select features that are based on attribute values. We won't do that now, just know that this option is available. One thing of note is that once you select a set of features, ArcGIS will perform subsequent functions only on those features. And sometimes that's what you want. But if not, remember to use the clear selection tool, which we will do now. Alright, to assign values, right click on the type column and select field calculator. If you haven't used field calculator before, I highly recommend learning about it, since it is a very useful tool for assigning values to vector features. And it has a lot more capability than we will use in this exercise. Now you can see that there's a large white box. And this is where your calculations are typed. And above the box, it says type equals, indicating that whatever calculations we do, they will be assigned to the type field. In this case, it's pretty simple. All we want to do is assign a value of one for all polygons. So we simply click in this window, type the number one in the calculation area, and then click OK. After a moment, you should see that all of the entries now have a value of one in their type field. Now that we have the vector layer prepared, let's create the damage loss table that goes along with these building polygons. Open a spreadsheet program. I'll use Excel, but you can use something else if you prefer. Looking back at the user guide, it says that the damage loss table must contain two fields type and damage. The type field has values that correspond with the ones that we just added to the building layer. And the damage field contains values of potential damage loss in currency per square meter. So let's add the two required columns to our table, type and damage. In our vector layer, we only assigned a single value of one to all of our building types. So under the type column, we can add the value one. For the damage loss per square meter, let's add an arbitrary value of 100. This is telling the model that any residential buildings that get flooded will incur a cost of $100 or whatever currency you're using per square meter. These values will be used by the model to calculate the value of avoided flooding due to natural infrastructure. Of course, in the real world project, you'd be researching this damage value much more carefully. Now that's a pretty simple table, but let's save it by clicking the save button, where it says save as type. We want to make sure to select CSV comma delimited. And then we're going to name this table damage loss dot CSV and click save. The next step of this process would be to test out your building layer and your damage table right by running them through invest. We won't do that now you can do that for homework. The actual data that was provided for this tutorial includes a folder called UFM model data, which contains the rest of the data required by the urban flood mitigation model. So please try out your new data by running it on your own. Next, we'll look at some of the invest errors that are related to vector layers. The buildings layer that we just looked at should work fine and invest, but what if it doesn't. What if we get an error. Listed here are several of the errors that you might encounter when running a model, if invest has problems processing the polygons in your vector layer. As you can see, there are a variety of these errors, and they are not particularly user friendly or self explanatory. So when we're trying to decipher these errors, keywords to look for our topology, geometry, polygon and ring, all of which you see highlighted here. Errors like this usually indicate that there's something incorrect about the geometry of one or more of your features, usually polygons like building footprints or watersheds. If you do get one of these errors, you'll need to go back to the GIS and use the check geometry and repair geometry tools. So let's try that now. First, let's find out what the geometry problems are. In our toolbox, go to data management tools, and then features, and then open up the check geometry tool. For the input features will just drag in buildings OSM shapefile, and for out to put table for expediency will just leave that as the default. Okay, and click okay. This tool creates a summary table with geometry information in it. But it also lists the errors that are found right here in the tool output window. Now if yours finished the same way minded, it found a null geometry in polygon ID 69 38 and a self intersection in polygon ID 69 39. Now we have two problems in the shapefile to fix these problems. We'll use the repair geometry tool in the same toolbox. The only input to this tool is the building shapefile. So let's drag that into the interface. There is an option here to delete features with null geometry. And this is checked by default. These features happen when there is an entry for a feature in the layer, but no actual point line or polygon to go along with it. In this case, it is best to just delete these features, since they cause problems not only for invest, but for other GIS tools as well. So we will keep that checked. And then we can click okay. Once the tool has finished, it will give information about any geometries that were repaired. And we can see that there is one feature with a null geometry that was deleted, and another feature with self intersections that were repaired. This corresponds with the output that we saw when running check geometry. Right, so this looks good. After you've used the repair geometry tool, try running the model again with a repaired layer. And that fixes the investor's and you can try that on your own. One other error you might get that's related to vector layers happens when you enter the shapefile or the geo package into the user interface. Red X's will appear next to the layer, such as the building footprint shown here. And you'll get a red X at the run button. When you click the X, a message will tell you what's wrong. In case the error says the fields are missing from the layer, and the missing field is named type. So if you get this error, you'll need to go back to the GIS session and check the attribute table, adding the type field and populating it with values, like we just described earlier in this tutorial. Okay, that's enough for this session. Remember to do your homework and run your new buildings layer and damage table through the urban flood mitigation tool. 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 web page, where you can search for previous posts and create a new post under the category of training. I and other techies at Nat Cap will see your post, and we will respond as soon as we can. Thanks for following along.