From the course: Python Scripting Using the ArcGIS API for Python
The data: Feature layers, feature services, feature sets
From the course: Python Scripting Using the ArcGIS API for Python
The data: Feature layers, feature services, feature sets
- [Instructor] In the ArcGIS API, there are several different classes for holding onto geospatial data. It's easy to get them confused. There are feature services, feature layer collections, feature layers and feature sets, and this is just a few of them. There are more. It's really important that a clear understanding of these terms and to know how to access each one, and also to know what the capabilities are of each one. Can I add it to a map? Can I send it into a geo processing tool? Can I get statistics on it or a feature count? Can I see its geometry type? It all depends on exactly what you're connecting to and how you're holding onto it. Let's talk about the spatial data as far as Python and the ArcGIS are concerned. Okay, I'm just going to discuss vector data right now. Points, lines and polygons. But you have similar concepts for Rasters and other spatial data types. So I have the ArcGIS API for Python reference Open. The feature layer is the primary concept of working with features in a GIS. You find the feature layer class here under the arcgis.features module. I'm here in ArcGIS online and I'm looking at the content that's been shared with groups that I belong to. You can see that I have access to quite a few feature layers and maps and apps. I'm going to filter, I'll search for just things related to Sturgis, which is a little town in Western Kentucky. Let's look at this one feature layer called Sturgis_Kentucky. I'll go over to its item details page, and in here I can see that this feature layer is actually a group layer that contains three individual layers, infrastructure, homes, and commercial buildings. Let me open this up in a map viewer. And in the map we'll be able to see that there are three individual layers on the map. This thing at the top is the feature layer collection. These guys down at the bottom are feature layers. So in a GOL and portal, it's just called a feature layer, but it has a different name over here in the API. It's called a feature layer collection. So a feature layer collection can consist of multiple feature layers. The API has both a feature layer collection class, and a feature layer class. The feature layer collection class has properties and methods, of course. You can see its properties and methods here. Notice that it has a manager class, which is a helper class used to manage the feature layer collection as a whole. Behind every feature layer is a feature service. The feature service is the actual data. So it's kind of like an ArcGIS Pro. You have a feature class in a geodatabase, and then you add that feature class to a map and it becomes a layer. It can have symbology and display properties, and it can be manipulated. So in the API, you have the feature service, the raw data, and then you bring it into AGL or portal, or into your script and it becomes a feature layer. And then it can have symbology and display properties and can be manipulated. Okay, so what about that feature set? A feature set is a collection of features. Basically the geometry and the attributes, stored in memory that is the result of a query or some analysis on a feature. So if you go run a buffer and it creates a buffer polygon, a bunch of buffer of polygons, they're stored in a feature set. Those are actual polygons and records. That's the raw data. Feature sets can't be directly added to a map in Arc, just notebooks. It's raw data. I first have to create a feature layer from the feature set to add it to the map. So let's see if we can recap on the feature layer, the feature service and the feature set. A feature layer is a representation of a single layer, either from a map service or a feature service. That single feature layer could be a component of a feature layer collection that I pull out of my portal. I can use the content.ad method of a map to add a feature layer to the map, or use the add to map method. And I can query it to perform analysis on it. A feature set though is a collection of features. Basically geometry and records from an attribute table stored in memory. That's the result of a query or some analysis. So feature services are layers. They have display properties. You can work with them in your notebook. Feature sets are the output of geo processing steps and queries and analysis done in the notebook. The feature set is sitting there in memory ready to continue to be analyzed, or you can convert it to a feature layer if you want, if you need to, if you want to display it on a map or save it in your AGL or portal. But I have to run a step, which we'll learn about to create a feature layer from the feature set. All right, so feature service, feature layer collection, feature layer, and feature sets. Those are some of the data types we have to work with. It's really important to think about the data type you're working with. If you want to use the data in a script, you have to grab hold of that feature service from its URL. You grab hold of it, and then it's a feature layer collection in your script and you can pull it apart into its individual feature layers.