Skip to content

extract_distance

This document has been machine translated.

Calculates the distance between each point in the transaction table.

The execution method uses JSON-RPC v2.0.

Example request

extract_distance is a type of analysis API that can be executed by specifying api_method="extract_distance" in the process method of the Provenance API. The following is an example of starting a provenance session, executing extract_distance, and ending the session.

import xdata_prov.client import Api
api = Api()
api.begin_session()

api.process(api_method="extract_distance", api_params={
    "output_ddc": "ddc:jartic_xrain_distances",
    "input_ddc": "ddc:jartic_xrain_transaction",
    "mesh_ddc": "ddc:jisx0410_mesh5",
    "code_column_name": "meshcode",
    "distance_method": "geography",
    "max_distance": 1000
})

api.commit()
api.end_session()

Parameters

When calling the process method as api_method="extract_distance", api_params takes a dict containing the following keys The default value, which is blank, is a required parameter.

Key Description Default Value
output_ddc registered to ddc
output_mode output mode (overwrite or error) error
input_ddc input data ddc
mesh_ddc mesh definition ddc
code_column_name column representing the mesh code in input_ddc
distance_method distance calculation method (geometry or geography)
max_distance upper limit of distance to output to output_ddc

Input data

Transaction table

The input ddc specified by input_ddc is a "transaction table". This table must have the following schema

column name data type description
id integer ID to uniquely identify the transaction
start_datetime timestamp with time zone start datetime
end_datetime timestamp with time zone end datetime
location geometry spatial extent
(meshcode) character varying meshcode
* arbitrary thematic attributes

| id | integer | ID to uniquely identify the transaction | start_datetime | timestamp with time zone | start_datetime | end_datetime | timestamp with time zone | end_datetime | location | geometry | spatial extent | | (meshcode) | character varying | meshcode | | * | arbitrary thematic attributes |

Normally, transaction tables store the meshcode in the meshcode column. However, the extract_distance function allows you to specify this column name via the code_column_name parameter.

mesh definition table

The input ddc specified by mesh_ddc is the "mesh definition table". This table must have the following schema

column name data type description
code text mesh code
geom geometry area
center geometry center coordinates

Note that the geom column is not used by the extract_distance function. It calculates the distance between the center coordinates indicated by the center column.

Output data

Distance table

A "distance table" is output to the destination ddc specified by output_ddc. This table has the following schema

column name data type description
item1 text mesh code
item2 text mesh code
distance double precision distance between mesh codes

Return values

extract_distance returns the ddc information of the destination ddc. This is the behavior defined by the specification of the process method of the Provenance API.