Description
An isochrone is a polygon connecting points that take the same amount of time to reach from a particular point. The IsoChrone function returns an isochrone connecting a set of points that can be reached from the specified starting location in the given duration.
The IsoChrone
UDF uses the GetTravelBoundary operation of the Global
Routing API to generate an isochrone. The GetTravelBoundary operation helps determine the
drive or walk time or the distance boundary from a given location. This function generates
polygons corresponding to an isochrone calculation. For more information, see the Global Routing SDK User Guide, which is
also available on the Spectrum Spatial for Big Data documentation landing page.
mapreduce.task.timeout
property.Function Registration
create function IsoChrone as 'com.pb.bigdata.spatial.routing.hive.IsoChrone';
Syntax
IsoChrone(WriteableGeometry startPoint, Number|String cost,
Map<String, String> options, Map<String, String> ambientOptions)
IsoChrone(WriteableGeometry startPoint, Array<Number|String> costs,
Map<String, String> options, Map<String, String> ambientOptions)
Parameters
Parameter | Type | Description |
---|---|---|
startPoint | WriteableGeometry | the location from which travel starts. This must be a point for those UDFs that require it. |
cost | Number or String | contains a single value for the maximum travel time (default unit is minute). |
costs | Array | contains multiple values for the maximum travel time (default unit is minute). When this parameter is provided, the UDF will return an array of responses, one for each cost, in the same order as the costs parameter. |
options | Map | options that affect the generation of the isochrone and engine options that affect the operation of the routing engine |
ambientOptions | Map | ambient road type options that affect the distance traveled when going off-network |
Syntax
IsoChrone(Number|String startX, Number|String startY, Number|String cost,
Map<String, String> options, Map<String, String> ambientOptions)
IsoChrone(Number|String startX, Number|String startY, Array<Number|String> costs,
Map<String, String> options, Map<String, String> ambientOptions)
Parameters
Parameter | Type | Description |
---|---|---|
startX | Number or String | x ordinate of the location from which travel starts in WGS 84 |
startY | Number or String | y ordinate of the location from which travel starts in WGS 84 |
cost | Number or String | contains a single value for the maximum travel time (default unit is minute). |
costs | Array | contains multiple values for the maximum travel time (default unit is minute). When this parameter is provided, the UDF will return an array of responses, one for each cost, in the same order as the costs parameter. |
ambientOptions | Map | ambient road type options that affect the distance traveled when going off-network |
Options
The options and ambientOptions keys cannot be derived from a column in the table that the UDF is executed on. The keys of the options and ambient-options maps must also be of type String or convertible to String, and the values should be convertible to a type appropriate for the key’s value (typically this means that all values must be of type String). Keys and values of any type can be enclosed in either double or single quotes; a number or Boolean value will be processed correctly with or without quotes. For information on options that affect the calculation of the route, see Engine Options.
Key | Type | Description |
---|---|---|
pb.routing.bandingStyle | BandingStyle | The style of banding to be used in the result. Banding styles are the types of
multiple distance bands that can be displayed based on multiple costs. The available
values are:
|
pb.routing.historicSpeedBucket | HistoricSpeedBucket | Specifies whether the routing calculation uses the historic traffic speeds.
These speeds are based on different time-of-day buckets. The data must have historic
traffic speeds included in order to use this feature. The data for each
country/region has the same bucket definitions, where the speeds for these bucket
values may vary. The available values are:
|
pb.routing.majorRoads | Boolean | Whether to include all roads in the calculation or just major roads. If you choose to include only major roads (that is, set the value to true), performance will improve but accuracy may decrease. The default value is false. |
pb.routing.returnHoles | Boolean | Specifies whether you want to return holes, which are areas within the larger boundary that cannot be reached within the desired time or distance, based on the road network. The default value is false. |
pb.routing.returnIslands | Boolean | Specifies whether you want to return islands, which are small areas outside the main boundary that can be reached within the desired time or distance. The default value is false. |
pb.routing.simplificationFactor | Number | What percentage of the original points should be returned or upon which the resulting complexity of geometries should be based. A number between 0.0 and 1.0 is accepted, exclusive of 0.0 but inclusive of 1.0. Complexity increases as the value increases, therefore 1.0 means the most complex. The default value is 0.5. |
pb.routing.maxOffroadDistance | Number | The maximum distance to allow travel off the road network using the pb.routing.maxOffroadDistanceUnit. Examples of off-network roads include driveways and access roads. For example, if you specify a maximum off road distance of 1 mile the travel boundary will extend no further than one mile from the network road. If you specify a value of 0 the travel boundary will not extend beyond the road itself. Use the ambient speed options to specify the speed of travel along non-network roads. |
pb.routing.maxOffroadDistanceUnit | String | The distance unit defining the
pb.routing.maxOffroadDistance. You must also define
pb.routing.maxOffroadDistance if you define this key. Available
linear units are:
|
pb.routing.timeUnit | String | The unit to return time. If not specified, the default value is minute.
Available time unit values are:
|
pb.routing.defaultAmbientSpeed | Number | The speed to travel when going off a network road to find the travel boundary (for all road types). To control how off-network travel is used in the travel boundary calculation, you need to specify the speed of travel off the road network (the ambient speed). Ambient speed can affect the size and shape of the travel boundary polygon. In general, the faster the ambient speed, the larger the polygon. For example, if you were at a point with 5 minutes left, and if the ambient speed were 15 miles per hour, boundary points would be put at a distance of 1.25 miles. If the ambient speed were reduced to 10 miles per hour, boundary points would be put at a distance of 0.83 miles. The default value is 15. |
pb.routing.ambientSpeedUnit | String | The unit of measure to use to calculate the ambient speed. Available speed units are: MPH (miles per hour), KPH (kilometers per hour), MTPS (meters per second), and MTPM (meters per minute). The default value is MPH. |
pb.routing.error.limit | Number | The number of routing errors to allow before failing a task for "too many
errors". This prevents a task (and thus the job) from continuing in the case of a
likely configuration error. The default value is 10. Optionally you can use the
equivalent Hive variable, |
pb.routing.error.limit.disabled | Boolean | Disables the error limit. All errors will be logged but will not cause the task
or job to fail. Optionally you can use the equivalent Hive variable,
|
Ambient Road Type Options
This option lets you adjust the distance traveled when going off-network
Key | Type | Description |
---|---|---|
RoadType | Number | Specifies the ambient speed to use for off-network travel based on the road type. You must specify both the road type and the new speed for that road type. The speed is defined in the options. Road types can be returned in all supported types. For a list of road type enumerations, see RoadType Enumeration. |
Return Values
This function returns struct values described in the table below. In the case where a single cost is input, a single struct is returned. In the case where an array of multiple cost values are input, then an array of structs are returned.
Return Field | Description |
---|---|
Geometry | The WritableGeometry of an isochrone. |
Error | Any error that occurs; if none, then null. |
Examples
SELECT ToWKT(IsoChrone(ST_Point(-77.088217, 38.937072), 600, map('pb.routing.timeUnit', 'second')).geometry);
SELECT ToWKT(IsoChrone(Geocode('485A Watervliet Shaker Rd, Latham, NY 12110','usa').geometry, 600).geometry);
SELECT ToWKT(IsoChrone(x, y, cost, map(pb.routing.engine.timeout, 300)).geometry) FROM <table_name>;
The previous example had the time-out specified as an number. It can also be specified as a string:
SELECT ToWKT(IsoChrone(x, y, cost, map(pb.routing.engine.timeout, '300')).geometry) FROM <table_name>;
SELECT ToWKT(IsoChrone(x, y, cost, map(pb.routing.engine.timeout, '300', 'pb.routing.allowFallback', 'false')).geometry) FROM <table_name>;
Example
showing ambient-options
set:SELECT ToWKT(IsoChrone(ST_Point(-77.088217, 38.937072), 3, null, map('footpath', '5')).geometry);
Example with both options
and ambient-options
set:
SELECT ToWKT(IsoChrone(ST_Point(-77.088217, 38.937072), 3, map('pb.routing.timeUnit', 'minute'), map('footpath', '5')).geometry);
Example showing multiple costs specified in an array for an input point. Hive requires that all values in an array must be of the same type:
SELECT costs[costidx] cost, ToWKT(iso.geometry) wkt, iso.error
FROM points
LATERAL VIEW explode(array(array(5,10,20))) c as costs
LATERAL VIEW OUTER posexplode(IsoChrone(points.longitude,points.latitude,costs)) isoresult as costidx, iso;