I'm storing some geo paths in PostGIS using GeoJSON and the ST_GeomFromGeoJSON()-function but I just found an issue with it:

SELECT ST_NumPoints(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[-122.023468,37.330232,0],[-122.02345,37.330233,0],[-122.02345,37.330233,0],[-122.023405,37.330236,0]]}')) = 4; -- FALSE

SELECT ST_NumPoints(ST_GeomFromText('LINESTRING (-122.023468 37.330232 0, -122.02345 37.330233 0, -122.02345 37.330233 0, -122.023405 37.330236 0)')) = 4; -- TRUE

It seems to strip the two 'middle' coordinates because they are the same. And I can buy that it would do that but it doesn't do it consistently, like when I use ST_GeomFromText() with the same list of coordinates. It also does not strip the coordinates when using "type": "MultiPoints" instead, but it would be the wrong semantics.

It's a problem for me because I need the points to match a sequence of timestamps as well or data will be lost. And the reason I'm using GeoJSON is that the app server is written in Javascript so it just seems natural.

I'm running Postgres 9.4.1 and SELECT PostGIS_Full_Version() gives me:

POSTGIS="2.1.5 r13152" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.11.1, released 2014/09/24" LIBXML="2.9.1" LIBJSON="UNKNOWN" RASTER
  • If anyone is curious I've worked around it by changing doing this little hack: ST_LineFromMultiPoint(ST_GeomFromGeoJSON('{"type":"MultiPoint","coordinates":[[-122.023468,37.330232,0],[-122.02345,37.330233,0],[-122.02345,37.330233,0],[-122.023405,37.330236,0]]}')) Feb 24, 2015 at 19:48

1 Answer 1


Yup, it's a bug. You can simplify it with:


 LINESTRING(0 0,1 1,2 2)

Which should be LINESTRING(0 0,1 1,1 1,2 2).

You should file a ticket to get it fixed. If you don't have a user ID, follow these instructions.

Update: postgis-2.1.6 and later have this fix. Also affected with similar behavior were GML and KML loader functions. To remove repeated points, since 2.0 you can use ST_RemoveRepeatedPoints.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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