1

I have a positions of half ellipsoid, these numbers represent coordinates of ellipsoid: Image

But when I try to save this coordinates, it throws an error like:

Geometry has Z dimension but column does not

I'm a newbie at Postgis, does anybody know how can I fix it?

datum
  • 11
  • 1

1 Answers1

1

This error message basically tells you that the geometry column in the database is not a 3D geometry (it doesn't have the Z value), hence you have to create, e.g. a POINTZ instead of a POINT. Same goes for LINESTRING and POLYGON and their "MULTI" versions.

28.1. 3-D Geometries

So far, we have been working with 2-D geometries, with only X and Y coordinates. But PostGIS supports additional dimensions on all geometry types, a “Z” dimension to add height information and a “M” dimension for additional dimensional information (commonly time, or road-mile, or upstream-distance information) for each coordinate.

For 3-D and 4-D geometries, the extra dimensions are added as extra coordinates for each vertex in the geometry, and the geometry type is enhanced to indicate how to interpret the extra dimensions. Adding the extra dimensions results in three extra possible geometry types for each geometry primitive:

  • Point (a 2-D type) is joined by PointZ, PointM and PointZM types.

  • Linestring (a 2-D type) is joined by LinestringZ, LinestringM and LinestringZM types.

  • Polygon (a 2-D type) is joined by PolygonZ, PolygonM and PolygonZM types.

    And so on.

Source: the PostGIS documentation for all the details: https://postgis.net/workshops/postgis-intro/3d.html

For example, create a table for storing 3D point geometries as:

CREATE TABLE my_table (
    id SERIAL PRIMARY KEY,
    name VARCHAR(64),
    geom geometry(POINTZ, 3857) -- for storing 3D point geometries
  );

Instead of:

CREATE TABLE my_table (
    id SERIAL PRIMARY KEY,
    name VARCHAR(64),
    geom geometry(POINT, 3857) -- for storing 2D point geometries
  );

Notice the removal of the trailing Z.

See also the PostGIS documentation chapter 4.6.1. Creating a Spatial Table.

swiss_knight
  • 10,309
  • 9
  • 45
  • 117
  • Thank you for your response and thanks for not judging me for being a newbie. I want to share my query and here it is:

    INSERT INTO public.geometries(shape) VALUES (ST_GeomFromText('GEOMETRYCOLLECTION (POLYGONZ ((30.165195709898388 36.4578143393434 21157.624029629347, 30.165195709898388 36.4578143393434 21157.624029629347, 30.165195709898388 36.4578143393434 21157.624029629347, ...)))', 4326));

    – datum Feb 27 '23 at 11:51