Skip to content


add support for 3D/4D postgis geometries #44

artemp opened this Issue · 3 comments

3 participants

Mapnik member

See [ thread on Mapnik users mailing list].


The PostGIS plugin/WKB reader assumes that geometries are in 2D. Though not standard OGC, PostGIS supports 3D/4D. There are two ways to fix this in Mapnik :

  1. Add support for 3D/4D Geometries in wkb reader

  2. Use force_2D inside postgis plug-in

Mapnik member

[artem] The third way is to use 'force_2D' in SQL :

(select name, type, force_2D(the_geom) as the_geom from roads) as roads_2d;

FYI ST_AsBinary(), which is called by Mapnik, doesn't drop M dimension. I suppose it doesn't drop Z too, but haven't yet tried on 3D data.
I've tested this:

select st_astext(st_geomfromwkb(st_asbinary(geom))) from m_geom;

for MULTILINESTRING M geometry in geom and the result was MULTILINESTRING M type, so it reconstructs wkt from wkb with the proper number of dimensions.

This leads to mapnik not rendering geometries with M dimension, and the only workaround yet is do a preliminary ST_Force_2D in a db.

Mapnik member

assigning to 2.3.x milestone - need to at least throw an error or handle more gracefully so this is not a totally silent problem.

@springmeyer springmeyer added a commit that referenced this issue
@springmeyer springmeyer add support for rendering (vs skipping) 3D and 4D postgis geometries …
@springmeyer springmeyer added a commit that referenced this issue
@springmeyer springmeyer add #44 to changelog fef45cb
@springmeyer springmeyer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.