Spectrum Spatial (SSA/LIM)

Expand all | Collapse all

New in 2019.1 - Using Route Network in Find Nearest

  • 1.  New in 2019.1 - Using Route Network in Find Nearest

    Employee
    Posted 01-08-2020 16:12
    Edited by Anne Thorne 01-08-2020 16:21

    The following write up is by Ovidiu Cilnician, a Senior Software Engineer on the Spectrum Spatial team.

    Introduction

    The Find Nearest stage provides the option to find the nearest candidates between an input geometry and a searching table.

    In the newly released 2019.1 version of Spectrum Spatial we added the ability to calculate the nearest candidates using a routing network.

    Now you can use find nearest either with a straight line or route network.

    In this presentation I will show how to use the Find Nearest stage to find the nearest candidates to an input point by using the routing network.

    I will demonstrate how to do this in two ways. First as a data flow executed as a job, secondly exposed as a web service.

    Use Case

    As an Insurance company, given a policy ID, I would like to understand the degree of risk from fire associated with each policy owner. To do this I will calculate a risk factor and append it to each policy ID. 

    The risk factor is appended to each policy holder based on the proximity to a fire station as follows:

    • less than 0.5 miles to a fire station is considered low risk.
    • less than 1 mile to a fire station is considered medium risk.
    • less than 2 miles to a fire station is considered high risk.
    • over 2 miles to a fire station is considered extreme risk.

    Work Flow

    • A policy id/location is used as an input.
    • Query Spatial Stage might be used to get more details about the policy (X/Y location)
    • Find Nearest Stage calculates the routing network distance based on the given point and the travel distance or time and returns the nearest candidates set by the stage. 
    • Returns the nearest fire stations. 

    You can visualize the output of this flow by using the routing demo page (http://localhost:8080/routingdemopage)

      

    Enterprise Designer Data Flow

    The Enterprise Designer tool is used to create the data flows.

    Job (batch) Processing

    • Read Spatial Data stage – Reads the US policies table.
    • Find Nearest stage (see Appendix for screen shots) – Uses the routing network to find the nearest candidates to the point from the previous stage. In our case the input point is a US policy and the nearest candidates are the fire stations.
    • Sorter stage – Sorts the nearest US fire stations by distance.
    • Transformer stage – Assigns risks to each US policy based on the distance to US fire stations.
    • Write to file stage – Writes the results to file.

    Web Service

    • Input - Creates a policy id field and exposes it to the web service.
    • Query Spatial Data - Performs a query against a US policies table (tab files) to find the candidate that matches the policy id passed from the previous stage.
    • Find Nearest - Uses the routing network to find out the nearest candidates to the point from the previous stage. In our case the input point is a US policy and the nearest candidates are the fire stations.
    • Sorter - Sorts the nearest candidates by policy id and distance.
    • Transformer - Creates a new field – RiskLevel. Assigns risks to each US policy based on the distance to US fire stations.
    • Output - Writes the results of the service.

    Exposing the Web Service         

    • The web service created in the previous step can be exposed as a SOAP or REST service by clicking the Expose/Unexpose and Save buttons from the Enterprise Designer menu.
    • To expose certain options/fields for the service, click Edit – Web Services Options.
    • Add the fields to be exposed. In this case I exposed the policy_id field.
    • More details about the exposed REST web service can be obtained from the WADL file.
    • http://localhost:8080/rest/FindClosestFireStationsForInsurancePoliciesService?_wadl
    • Service URL
      • http://<<ip_address>>:8080/rest/FindClosestFireStationsForInsurancePoliciesService/${Data.policy_id}/results.json
      • http://<<ip_address>>:8080/rest/FindClosestFireStationsForInsurancePoliciesService/${Data.policy_id}/results.xml

     


    Using the Service
    • A policy ID is passed to the service:
      • http://<<ip_address>>:8080/rest/FindClosestFireStationsForInsurancePoliciesService/1501615095/results.json
    • The closest 3 fire stations are returned.
    • Result:

    {
                  "Closest_Fire_Stations": [{
                                 "FireStation_Id": "10523507",
                                 "FireStation_Name": "CITY OF LOS ANGELES FIRE DEPARTMENT STATION 9",
                                 "FireStation_Address": "430 EAST 7TH STREET",
                                 "FireStation_City": "LOS ANGELES",
                                 "FireStation_State": "CA",
                                 "Distance": 0.5536417322834645,
                                 "DistanceUnit": "mi",
                                 "Time": 3.6,
                                 "TimeUnit": "min",
                                 "RiskLevel": "Medium Risk",
                                 "FireStation_County": "LOS ANGELES",
                                 "Policy_id": "1501615095",
                                 "Policy_address": "127 EAST 9TH STREET",
                                 "Policy_city": "LOS ANGELES",
                                 "Policy_state": "CA",
                                 "Policy_zip": "90015",
                                 "user_fields": []
                  }, {
                                 "FireStation_Id": "10523508",
                                 "FireStation_Name": "CITY OF LOS ANGELES FIRE DEPARTMENT STATION 10",
                                 "FireStation_Address": "1335 SOUTH OLIVE STREET",
                                 "FireStation_City": "LOS ANGELES",
                                 "FireStation_State": "CA",
                                 "Distance": 0.9258430764336275,
                                 "DistanceUnit": "mi",
                                 "Time": 5.4,
                                 "TimeUnit": "min",
                                 "RiskLevel": "Medium Risk",
                                 "FireStation_County": "LOS ANGELES",
                                 "Policy_id": "1501615095",
                                 "Policy_address": "127 EAST 9TH STREET",
                                 "Policy_city": "LOS ANGELES",
                                 "Policy_state": "CA",
                                 "Policy_zip": "90015",
                                 "user_fields": []
                  }, {

                                 "FireStation_Id": "10523402",
                                 "FireStation_Name": "CITY OF LOS ANGELES FIRE DEPARTMENT STATION 3",
                                 "FireStation_Address": "108 NORTH FREMONT AVENUE",
                                 "FireStation_City": "LOS ANGELES",
                                 "FireStation_State": "CA",
                                 "Distance": 1.790170404835759,
                                 "DistanceUnit": "mi",
                                 "Time": 9.916666666666666,
                                 "TimeUnit": "min",
                                 "RiskLevel": "High Risk",
                                 "FireStation_County": "LOS ANGELES",
                                 "Policy_id": "1501615095",
                                 "Policy_address": "127 EAST 9TH STREET",
                                 "Policy_city": "LOS ANGELES",
                                 "Policy_state": "CA",
                                 "Policy_zip": "90015",
                                 "user_fields": []
                  }]}

    Appendix

    Data

    • Routing data - US_Driving.spd 2018, Driving edition.
    • Spatial data
      • Tab file (can use a csv or a text file as well) that contains all US policies - 16743 records.
      • Tab file that contains all US fire stations - 53087 records.

     Configuration

    • Routing data is configured using Management Console.
    • Spatial data is configured using Spatial Manager.
    • Remote Component Pool size and the memory should be high enough for each component in order to accommodate the workload.

    Create a Routing Database

    • Drop the SPD file (US_Driving.spd) into the Spectrum import directory (…/server/import).
    • Use the Management Console to register the routing database.
    • Click Resources/Spectrum Databases.
    • Click the + button to add a database.
    • Select Spatial module and the Routing type to register the routing database.
    • As I used the US Driving database, the Driving Network Type with the available Routing database appears.
    • Select the database, modify the Pool size and the Max memory accordingly and click Save.
    • The database should be available once Status has a check mark.

    Create named resources

    • Use Spatial Manager to create the named connections and named tables that you need.
    • Named connections should point to a folder that contains the data (tab files).
    • Named tables will be created from the named connections.

    Find Nearest Stage

    Input

    • Point from a previous stage.
    • Named table that is used to find candidates that are within a certain travel boundary is configured.

    Settings

    • Routing Database to be used.
    • Number of candidates to be returned.
    • Search distance/time to be used.
    • Optimized routing by distance or time.
    • Output fields to be returned from the Routing calculation.

    Output

    • Fields to be returned from the searching table.

    Performance

    • The network polygon is created by the Routing engine based on the searching distance/time.
    • A lot of time is spent calculating/returning all the points that are within the network polygon. This is done on the Spatial side.
    • When the data is dense, a combination of searching distance/time and the required number of candidates should be used.
    • Using a high distance for a dense dataset might cause performance problems as a high number of candidates will be found within the network polygon. The routing engine needs to calculate a matrix between the searching point and a big number of candidates.
    • When the data is sparse an appropriate distance (higher) should be used.

    Here is a related article which demonstrates Find Nearest using a straight line



  • 2.  RE: New in 2019.1 - Using Route Network in Find Nearest

    Posted 01-09-2020 08:49
    Thank you for sharing this documentation. We would like to know if using routing data to find the nearest locations requires ERM module or only Spatial.
    Thanks!

    ------------------------------
    Amine Kriaa
    Knowledge Community Shared Account
    ------------------------------



  • 3.  RE: New in 2019.1 - Using Route Network in Find Nearest

    Employee
    Posted 01-09-2020 09:31
    FindNearest works without routing data but the calculations are just straight line. To use the features in this article requires installing the routing data. ​

    ------------------------------
    Eric Blasenheim
    Spectrum Spatial Technical Product Manager
    Troy, NY
    ------------------------------



  • 4.  RE: New in 2019.1 - Using Route Network in Find Nearest

    Employee
    Posted 01-09-2020 09:35
    To clarify in case this is not obvious, to use routing data means that you have a license for the data. The ERM module (code) is always installed when you pick Spatial (or LocationIntelligence in the past).  So the ERM is there but without data there is nothing. Same as for Geocoding and Address Validation but they have their own install options.


    ------------------------------
    Eric Blasenheim
    Spectrum Spatial Technical Product Manager
    Troy, NY
    ------------------------------