Files
Introduction
A common GIS operation is to overlay two (or more) polygons to subtract the area of one polygon from another.
For example, you might have a polygon representing the outline of a town or city. You also have a dataset of polygons representing residential areas. By overlaying the two, you can subtract one from the other to identify non-residential areas of the city.
FME has several transformers that will overlay data, but to cut out parts of a polygon, the best solution is the Clipper transformer.
Video
This video was recorded using FME 2016. The concepts are still the same, but the FME interface is different.
Source Data
The source datasets for this example are a set of park polygons (in MapInfo TAB format) and a set of building polygons (in AutoCAD DWG format). In the Visual Preview (or FME Data Inspector), it looks like this:
Map tiles by Stamen Design, under CC-BY-3.0. Data by OpenStreetMap, under CC-BY-SA.
A common task is to calculate the area of parks to assess what grounds maintenance needs to be carried out. Of course, this should not include the area occupied by buildings. This example builds a workspace to subtract building footprints from parks before measuring the parks' areas.
Step-By-Step Instructions
A completed workspace is available in the Files section of this article. You can also download the zip file containing the data and follow along with the tutorial on your own.
1. Add Autodesk AutoCAD DWG/DXF Reader
Open FME Workbench and start a new workspace. Add a reader to the canvas and set the following:
- Format: Autodesk AutoCAD DWG/DXF
-
Dataset: BuildingFootprints.dwg
- Click on the ellipses to navigate to the location of the file on your computer
Then click OK.
In the Select Feature Types dialog, unselect 0, and then click OK. We are only interested in the BuildingFootprints layer.
2. Add a MapInfo TAB (MITAB) Reader
Now we will read in the Parks dataset. Add another reader to the canvas and set the following:
- Format: MapInfo TAB (MITAB)
-
Dataset: Parks.tab
- Click on the ellipses to navigate to the location of the file on your computer
Click OK.
3. Calculate Park Area
Next, we need to determine the total area of each park before subtracting the building area. Add an AreaCalculator to the canvas and connect it to the Parks reader feature type. In the parameters, change the Output Area Name to TotalParkArea
4. Clip BuildingFootprint from Park
Using the Clipper, we will clip the Park with the BuildingFootprint. Add a Clipper to the canvas and connect the BuildingFootprint reader feature type to the Clipper input port, and the AreaCalculator Output port to the Candidate (Clippee) input port.
In the Clipper parameters, confirm that Multiple Clippers is set to Yes. We need to ensure this is set to Yes, as there may be several buildings within a single park.
5. Calculate the New Park Area
With the BuildingFootprints clipped from the Parks, we can now determine the new Park area with another AreaCalculator. Add an AreaCalculator to the canvas and connect it to the Output output port on the Clipper. The Outside port will be the parts of the park features that fall outside of a BuildingFootprint.
In the AreaCalculator_2 parameters, change the Output Attribute Name to ParkLandArea, then click OK.
6. Inspect Output
Add an Inspector transformer to the canvas and connect it to the AreaCalculator_2 output port. Run the workspace and view the output in Visual Preview.
In Data Preview, you will see that each park has had its building footprints removed and that it has an area measurement both with and without the buildings.
Map tiles by Stamen Design, under CC-BY-3.0. Data by OpenStreetMap, under CC-BY-SA.
To determine whether a park has a building cutout, check the _clipped attribute. If that attribute is set to no, then the before and after areas should be the same.
Data Attribution
The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.