由于GPS精度以及系统误差等原因,造成gps轨迹数据像狗啃一样,不是那么规则,且大多数点无法落在道路上,因此这篇文章主要是对GPS轨迹数据进行处理。
1、原始数据为csv格式数据,具体怎么将csv数据转化为空间数据就不多赘述。以下为gps数据表格,此处已简化数据规模,表中只有一条轨迹,便于计算。
CREATE TABLE "public"."gps_data" (
"gid" int4 DEFAULT nextval('gps_data_gid_seq'::regclass) NOT NULL,
"date" date,
"time" varchar(254) COLLATE "default",
"latitude" numeric,
"longitude" numeric,
"altitude" numeric,
"speed" numeric,
"course" int4,
"type" int4,
"distance" numeric,
"essential" int4,
"geom" "public"."geometry",
CONSTRAINT "gps_data_pkey" PRIMARY KEY ("gid")
)
WITH (OIDS=FALSE)
;
ALTER TABLE "public"."gps_data" OWNER TO "postgres";
CREATE INDEX "gps_data_geom_idx" ON "public"."gps_data" USING gist ("geom");