span8
span4
span8
span4
The FeatureReader,SpatialRelator and SpatialFilter transformers are great tools for performing spatial queries on data in FME workbench.They allow you to quickly select your query parameters without the need to fuss over the syntax of database-specific SQL.
This article describes how to use the FeatureReader to perform spatial and/or attribute queries.In workbench,you need to connect the features you wish to use in your spatial query to the Initiator port of the FeatureReader transformer.If you're performing a spatial query,it is important that the geometry of the query feature is in the same coordinate system as those to be read using the FeatureReader.The CSMapReprojector or Reprojector transformers can be used for this purpose.
Spatial Query using FeatureReader - FME 2017
Spatial Query using FeatureReader - FME 2016
The download spatialquery-featurereader.fmwt is the complete workspace.If you would like to create the workspace yourself,please download vancouverneighborhoods.kml,and follow the steps below to create it.
Complete workspace
1.Inspect Source Data
Add a Google KML Reader and set Dataset to VancouverNeighborhoods.kml.In Data Inspector,please note the different neighborhood polygons,one neighborhood will be used to create a spatial query in the FeatureReader.
VancouverNeighborhoods.kml in Data Inspector
2.Reproject
The source KML data must be in the same coordinate system as the database data.KML is always in the LL84 coordinate system.Add a CsmapReprojector,leave the Source Coordinate System as
3.Extract Bounding Box
The Tester extracts an area of interest to be used in the spatial query.In this example,one of the neighborhoods,Fairview,is used.You could build a parameter that is a list of 'hoods.
4.Add FeatureReader
For Format please enter PostGIS and set Dataset to Embed Connection Parameters.Under Parameters...please enter:
Host:postgis.train.亚搏在线safe.com
Port: 5432
Database: fmedata
Username: fmedata
Password: fmedata
Schema: fmedata2015
Set Schemas for Table Listing to fmedata2015
In Feature Types to Read,please choosePostalAddress.
Setup the query Constraints parameters of the FeatureReader.To perform a spatial query select a spatial predicate using the Spatial Filter parameter.In this example,Spatial Filter is set to Contains so that only features which are within the Fairview neighborhood polygon will be returned.
FeatureReader parameter Spatial Filter set to Contains spatial predicate
You can use the WHERE Clause parameter to constrain the data using an attribute query.Note that this WHERE clause will be applied to all the tables you've selected to read.Try adding a WHERE Clause and compare the difference:
"Status" not like 'Retired'
5.Inspect Result
When the result of the query along with the bounding box is sent to the Data Inspector,we can see that the FeatureReader returns only the point features that are contained by the bounding area - the Fairview Neighborhood.
PostalAddress points within the Fairview neighborhood
Let the database do the work is a good adage to follow when ever possible.Having the database perform the spatial query and return only the query results is generally going to give better performance than reading the entire table and filtering in FME.
Another example showing how to use theSQLExecutor to perform a native spatial query.
Extracting Data within a Clipping Polygon using FeatureReader
How to Read and Translate all Feature Classes from Multiple Esri Geodatabases
Performing native spatial queries on database tables using the SQLExecutor
Using the InlineQuerier as a replacement for multiple FeatureMergers
Creating and Associating Geodatabase Domains Dynamically Using A Feature Class and GDB Table
Using the SQLExecutor or SQLCreator to issue commands to a database
Extract Geodatabase Coded Domain Definitions
© 2019 亚搏在线Safe Software Inc |Legal