Preparing routing data for pgRouting
- It is important that you already have postgres, postgis, pgRouting installed in your machine.
A. The schema. Below is the sample schema that is a derivative of the kanagawa sample data from pgRouting. Take note of the source and target nodes, as well as the length and the node coordinates (x1,y1; x2,y2) of the line.
cybersoftbj=# \dt List OF relations Schema | Name | TYPE | Owner --------+------------------+-------+---------- public | geometry_columns | TABLE | postgres public | roads | TABLE | postgres public | spatial_ref_sys | TABLE | postgres (3 ROWS) |
cybersoftbj=# \d roads TABLE "public.roads" COLUMN | TYPE | Modifiers ------------+------------------------+----------------------------------------------------- gid | INTEGER | NOT NULL DEFAULT NEXTVAL('roads_gid_seq'::regclass) rd_id | BIGINT yutu_id | INTEGER block_id | BIGINT heirarchy | CHARACTER VARYING(5) cn_name | CHARACTER VARYING(75) py_name | CHARACTER VARYING(100) SOURCE | BIGINT target | BIGINT x1 | NUMERIC y1 | NUMERIC x2 | NUMERIC y2 | NUMERIC costlength | NUMERIC the_geom | geometry |
A. Extracting the coordinates of the line segments from Mapinfo.
- I have to format the data structure as follows…
…here is the roads table after weeding out some unnecessary columns…
… adding the source,target,x1,y1,x2,y2,costlength…
- Using ObjectGeography. Download the MapBasic Reference
ObjectGeography( object, attribute )
ObjectGeography( object, “1” ) <– gives you the beginning x coord of the point
- Export the tab file to a shape file for ArchMap.