{"action":"created","issue":{"url":"https://api.github.com/repos/ropensci/geojsonio/issues/58","labels_url":"https://api.github.com/repos/ropensci/geojsonio/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/ropensci/geojsonio/issues/58/comments","events_url":"https://api.github.com/repos/ropensci/geojsonio/issues/58/events","html_url":"https://github.com/ropensci/geojsonio/pull/58","id":81125981,"number":58,"title":"Allow setting precision of coordinates in geojson_write","user":{"login":"ateucher","id":2816635,"avatar_url":"https://avatars.githubusercontent.com/u/2816635?v=3","gravatar_id":"","url":"https://api.github.com/users/ateucher","html_url":"https://github.com/ateucher","followers_url":"https://api.github.com/users/ateucher/followers","following_url":"https://api.github.com/users/ateucher/following{/other_user}","gists_url":"https://api.github.com/users/ateucher/gists{/gist_id}","starred_url":"https://api.github.com/users/ateucher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ateucher/subscriptions","organizations_url":"https://api.github.com/users/ateucher/orgs","repos_url":"https://api.github.com/users/ateucher/repos","events_url":"https://api.github.com/users/ateucher/events{/privacy}","received_events_url":"https://api.github.com/users/ateucher/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-05-26T20:36:58Z","updated_at":"2015-06-10T20:38:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ropensci/geojsonio/pulls/58","html_url":"https://github.com/ropensci/geojsonio/pull/58","diff_url":"https://github.com/ropensci/geojsonio/pull/58.diff","patch_url":"https://github.com/ropensci/geojsonio/pull/58.patch"},"body":"I don't think this is ready for merging yet - I haven't written any tests, or even manually tried all the methods, but thought I would put it out there to see what you think.\r\n\r\n`ogr2ogr` by default seems to put a ridiculous amount of precision in the coordinates when creating GeoJSON, which can make file sizes unnecessarily large. There is a COORDINATE_PRECISION argument to `ogr2ogr` which allows you to set the number of decimal places in the coordinates.\r\n\r\nThis PR adds a `precision` argument to `write_ogr`, `write_geojson` and all `geojson_write` methods which use those functions.\r\n\r\nFor example:\r\n```r\r\npoly <- list(c(-114.345703125,39.436192999314095),\r\n          c(-114.345703125,43.45291889355468),\r\n          c(-106.61132812499999,43.45291889355468),\r\n          c(-106.61132812499999,39.436192999314095),\r\n          c(-114.345703125,39.436192999314095))\r\ngeojson_write(poly, file = \"foo.geojson\", geometry = \"polygon\")\r\ngeojson_write(poly, file = \"foo2.geojson\", geometry = \"polygon\", precision = 2)\r\n# Look at the first line of coordinates\r\nreadLines(\"foo.geojson\", n = 5)[5]\r\nreadLines(\"foo2.geojson\", n = 5)[5]\r\nfile.info(\"foo.geojson\")[\"size\"]\r\nfile.info(\"foo2.geojson\")[\"size\"]\r\n```\r\n![capture](https://cloud.githubusercontent.com/assets/2816635/7822682/1d540b6a-03ac-11e5-8553-a13009212b62.PNG)\r\n"},"comment":{"url":"https://api.github.com/repos/ropensci/geojsonio/issues/comments/110905962","html_url":"https://github.com/ropensci/geojsonio/pull/58#issuecomment-110905962","issue_url":"https://api.github.com/repos/ropensci/geojsonio/issues/58","id":110905962,"user":{"login":"ateucher","id":2816635,"avatar_url":"https://avatars.githubusercontent.com/u/2816635?v=3","gravatar_id":"","url":"https://api.github.com/users/ateucher","html_url":"https://github.com/ateucher","followers_url":"https://api.github.com/users/ateucher/followers","following_url":"https://api.github.com/users/ateucher/following{/other_user}","gists_url":"https://api.github.com/users/ateucher/gists{/gist_id}","starred_url":"https://api.github.com/users/ateucher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ateucher/subscriptions","organizations_url":"https://api.github.com/users/ateucher/orgs","repos_url":"https://api.github.com/users/ateucher/repos","events_url":"https://api.github.com/users/ateucher/events{/privacy}","received_events_url":"https://api.github.com/users/ateucher/received_events","type":"User","site_admin":false},"created_at":"2015-06-10T20:38:31Z","updated_at":"2015-06-10T20:38:31Z","body":":+1:  awesome"}}