span8
span4
span8
span4
Previous: Select Data by Area Masks
In this tutorial,you will learn how to convert raster data into polygons using the RasterToPolygonCoercer transformer.
Note: Since you areworking on a public facing database,tables can occasionally be overwritten and/or modified.If your translation produces unexpected results,see theResetting the PostGIS Training Databasearticle.Alternatively,you can download the provided file(s) and replace the PostGIS reader with a reader of the appropriate format.
In this scenario,you want to convert a 1m raster of urban and park areas into a city boundary polygon that will be stored in the KML format.
The RasterToPolygonCoercer creates polygons from input raster features.One polygon is output for each contiguous area of pixels with the same value in the input raster.
Notice the raster was properly converted to polygon features which are classified by the _label attribute.The selected area identifies the raster background (_label 0,0,0,0) which will be removed using a Tester transformer in the following step.The RasterToPolygonCoercer creates the _label attribute that represents the band values covered by that polygon (in this case R,G,B,A).In the original dataset,there are three classified cell values: urban,park,and background.Although the dataset appears to be clipped to the land boundary,the background cells still have values (0,0,0,0) but have been made transparent.Since the background cells still have values,they made into polygons by the RasterToPolygonCoercer.
Recall from the previous step (as indicated in the screenshot above) that the raster background had a value of 0,0,0,0 for the _label attribute.
To learn more about the Tester and Test Clauses,see theTester and TestFilter Transformerssection in the FME Desktop Basic Training Manual.
In this scenario,you only have to set the Generalization Tolerance.The larger the Generalization Tolerance,the smoother the line.
If you were to run the workspace and inspect the output in the FME Data Inspector at this stage,you would notice the polygon is very jagged as it follows the outline of the raster cells similar to the screenshot provided below:
To avoid this,you need to smooth the lines by reducing the density of coordinates by removing vertices.To learn more about smoothing lines using a generalizing algorithm,see theGeneralizer Documentation.
Note: the unit of this value is controlled by the coordinate system of the feature(s) that were read in.
Generalization Tolerance 1:
Generalization Tolerance 10:
After running the translation,you will have a new Google KML file with a single polygon for the Vancouver land boundary.Since you attached an Inspector to the last transformer on the canvas,the output will automatically open in the FME Data Inspector.
Data used in this tutorial originates from open data made available by theCity of Vancouver,British Columbia.It contains information licensed under the Open Government License - Vancouver.
© 2019 亚搏在线Safe Software Inc |Legal