Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to understand creation of a geoprocess with ModelBuilder, but I don't know why it's important to use feature layers instead of feature classes when creating a geoprocess with ModelBuilder. Can someone please explain why?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

Models may have many sub process output layers depending on their size and complexity. To eliminate files being written onto your hard disk, some tools make you use feature layers (e.g. Iterate Feature Selection, or Select by Attribute). Feature layers are temporary and will not persist after your model ends.

See Make Feature Layer

share|improve this answer
    
Thank you very much, Art –  Diego Pardo May 7 '13 at 2:33
add comment

There are a couple of reasons why you want to reference Feature Layers in ModelBuilder, as opposed to Feature Classes. First it is helpful to understand the differences.

  • "Feature Classes" as simply references to the raw data, in its entirety. One simple example of this where the FC is a shapefile on disk.
  • "Feature Layers" are references to an abstraction of the data, where you can interact with one or more of the features in the raw dataset (as opposed to the entire dataset). Layers are what you are effectively interacting with once you have loaded the data into ArcMap.

So given that background, here are some reasons why you want to use the "Make Feature Layer" tool as a go-between from the raw data and other geoprocessing tools.

  1. Many GP tools in ModelBuilder require the use of a layer, and will not accept an FC as input. This is particularly true if your GP tool(s) need to select data. In this scenario, you need to interact with the LAYER, not the raw data. Example: If you didn't have ArcMap (or another GIS program) open, how would you select features from the raw shapefile... you can't. You need to interact with the layer in ArcMap to make that selection.
  2. If you would like to run a Model from ArcCatalog, or export your Model to a Python script that can be run outside of ArcGIS, you need to use "Feature Layers" in order to have your raw source data be converted to "Layers". This would be analogous to "adding data" to your ArcMap session.

  3. Using layers makes it easy to subset your data as you go along in the ModelBuilder process. Say you wanted to process all data with attribute "A" with one method, but all data with attribute "B" with another method. You can reference your raw data once, then split the data into two "branches" using Feature Layers and process each set independently, but affecting/updating the single source dataset.

  4. You can create "in_memory" feature layers that are truly temporary data processing "bins", and which can process the data much more rapidly than writing to disk after every operation. It also limits the amount of junk you have to clean up after your processing is complete.
share|improve this answer
    
Thank you very much Ryan. Your answer is very complete and clear. –  Diego Pardo May 7 '13 at 2:27
add comment

Incorporating temporary layers into your models also decreases processing time. From a processing standpoint, it is much more efficient writing to memory compared to writing to disk. Similarly, you can write temporary data to in_memory workspace, which is also more computationally efficient.

Many operations in ArcGIS require temporary layers as inputs. For example, Select Layer By Location (Data Management) is a very powerful and handy tool that allows you you select features of a layer that share spatial relationships with another selecting feature. You can specify complex relationships such as "HAVE_THEIR_CENTER_IN" or "BOUNDARY_TOUCHES", etc.

Edit:

Out of curiosity, and to elaborate on processing differences using feature layers and in_memory workspace, consider the following speed test where 39,000 points are buffered 100m:

import arcpy, time
from arcpy import env

# Set overwrite
arcpy.env.overwriteOutput = 1

# Parameters
input_features = r'C:\temp\39000points.shp'
output_features = r'C:\temp\temp.shp'

###########################
# Method 1 Buffer a feature class and write to disk
StartTime = time.clock()
arcpy.Buffer_analysis(input_features,output_features, "100 Feet")
EndTime = time.clock()
print "Method 1 finished in %s seconds" % (EndTime - StartTime)
time.sleep(5)

############################
# Method 2 Buffer a feature class and write in_memory
StartTime = time.clock()
arcpy.Buffer_analysis(input_features, "in_memory/temp", "100 Feet")
EndTime = time.clock()
print "Method 2 finished in %s seconds" % (EndTime - StartTime)
time.sleep(5)

############################
# Method 3 Make a feature layer, buffer then write to in_memory
StartTime = time.clock()
arcpy.MakeFeatureLayer_management(input_features, "out_layer")
arcpy.Buffer_analysis("out_layer", "in_memory/temp", "100 Feet")
EndTime = time.clock()
print "Method 3 finished in %s seconds" % (EndTime - StartTime)
time.sleep(5)

enter image description here


We can see that methods 2 & 3 are equivalent and roughly 3x faster than method 1. This shows the power of using feature layers as intermediate steps in larger workflows.

share|improve this answer
    
This seems to be conflating two things (in-memory data and feature layers). They are not the same. Data written to the in_memory workspace is still data (e.g. feature classes and tables) still takes up (potentially lots of) space. Feature Layers, on the other hand, are a view over the data, allowing you to select a subset of the data and use it in subsequent processes, rather than duplicate data just to get a subset of it. Feature Layers take up almost no space at all. I like to think of them as "pointers with metadata", e.g. they point to some data and describe how to query/render it. –  blah238 May 3 '13 at 19:44
    
Just to add to my previous comment, I have read somewhere on this site that the in-memory workspace is basically a file geodatabase that sits in memory, if you like to think of it that way. –  blah238 May 3 '13 at 19:46
    
Like a file geodatabase but shape areas are not calculated when in_memory - will provide link to this later. –  PolyGeo May 4 '13 at 2:27
    
In your updated second example, you are creating a feature class in-memory, not a feature layer. –  blah238 May 4 '13 at 5:52
    
Aaron, Blah, Poly: TThank you very much to all. The demonstration Python script is revealing. –  Diego Pardo May 7 '13 at 2:31
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.