Recently, I was studying spatialite.I can write 2D data(like this:POINT(1 1)) into the spatial data table,but I can't write 3D data(like this:POINT(1 1 1) ) into the spatial data table. Who can tell me spatialite whether support 3D? If support ,how can I write a 3D data?
Asked
Active
Viewed 2,454 times
1
-
No, spatial indexes are implemented as r-trees, which are inherently 2 dimensional (they sort objects based on the rectangle the points of the object lie in), so if you need a 3rd dimension, you have to implement it in some other way (e.g. store z or the point (x,z) in a second column). – Solarflare Sep 01 '17 at 07:49
2 Answers
0
Yes, Spatialite supports 3D geometries (actually 2.5D geometries).
On why it does not work for you, probably your geometry column is not defined as XYZ
. You can check geometry metadata with the query:
SELECT * FROM geometry_columns;

Sga
- 3,608
- 2
- 36
- 47
0
To add points with three 3 dimensions you have to use the correct WKT expression: POINTZ(x,y,z)
.
(see also: https://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/wkt-wkb.html)
You also have to make sure, that you geometry column is correctly defined as XYZ column. (see functions: Dimension
CoordDimension
Is3D
). GeometryType
should therefore return POINTZ
(see also: http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.0.html)

Marcel Gangwisch
- 8,856
- 4
- 23
- 32