In the Shapely package, there is a function that allows you to determine whether coordinates include a Z value. It is object.has_z.

Is there a way that a similar command can be carried on the geometry column of a SQLite table?


If you have a SpatiaLite database you can use the SQL function ST_Is3D http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html. Example that returns "1" as a result

SELECT ST_Is3d(ST_GeomFromText('POINTZ (1 1 1)'));

CoordDimension and ST_NDims can by used as well, the first returns "XYZ" and the latter "3" but I think that ST_Is3D is the best match for you.

  • I tried that but I get "-1" as a results, which the link says is "for UNKNOWN corresponding to a function invocation on invalid arguments." I am calling it with this code conn.execute("SELECT ST_Is3d(ST_GeomFromText('a_table'));"). Is that correct?
    – Perfalcon
    Jun 4 '19 at 13:24
  • 1
    No, that's not correct SQL. If your table is named "my_table" and the geometry field is "geom" do SELECT ST_Is3D(geom) FROM my_table.
    – user30184
    Jun 4 '19 at 13:28

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.