2

For the following SQL, I create a GeoJSON from a valid geometry, which makes it invalid:

select st_asgeojson(geometry, 6), st_isvalid(geometry), st_isvalid(st_geomfromgeojson(st_asgeojson(geometry, 6)))
from bd_region
where id = 310100;

the output:

{some GeoJSON}, true, false

the output JSON is here: https://jsonblob.com/c62204c1-03f1-11e8-8467-f5eea275e9a5

After a search I found that may due to precision reason. How can I fix it?

  [
    [
      121.412516,
      31.244891
    ],
    [
      121.41456,
      31.243229
    ],
    [
      121.41456,
      31.243229
    ],
    [
      121.412516,
      31.244891
    ]
  ],
  • Have you tried using ST_MakeValid(st_geomfromgeojson(st_asgeojson(geometry, 6))) – Liam G Jan 28 '18 at 8:55
  • 1
    did you try change the precision from 6 to something else ? the default value is 15 by good reason (e.g. to avoid these problems). – pLumo Jan 29 '18 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.