2

Using:

CREATE TABLE trajectories(
gid SERIAL PRIMARY KEY,
vehID VARCHAR(10),
state INTEGER,
geom geometry(MULTILINESTRING)
)

I get an error, for instance, after inserting:

INSERT INTO trajectories(vehid,state,geom)
VALUES(001140,2,ST_GeomFromText('MULTILINESTRING((1 2 3,4 5 6))'))

it gives:

Geometry has Z dimension but column does not.

How could I circumvent this error?

4

Using

-- DROP TABLE trajectories;

CREATE TABLE trajectories
(
  gid serial NOT NULL,
  vehid character varying(10),
  state integer,
  geom geometry(MultiLineStringZ),
  CONSTRAINT trajectories_pkey PRIMARY KEY (gid)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE trajectories
  OWNER TO postgres;

Your INSERT will be ok.

Indeed: in your code the geom column does not have Z dimension.

0

Check if your column type is geometry if so you need to convert into

ALTER TABLE trajectories 
  ALTER COLUMN geom TYPE geometry(MultiLineStringZ)
    USING ST_Force_3D(geom);

This will force the column to hold Z value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.