Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add precision variable to geojson_list() #152

Merged
merged 7 commits into from Oct 14, 2019
Merged

Add precision variable to geojson_list() #152

merged 7 commits into from Oct 14, 2019

Conversation

ChrisJones687
Copy link
Contributor

@ChrisJones687 ChrisJones687 commented Oct 3, 2019

Description

Added precision argument to geojson_rw() with default to NULL to avoid changing behavior when the argument isn't used. Then used this change to add precision to geojson_list() specifically for all sp class calls. I haven't tested this for non-sp classes yet.

Related Issue

related to #141 for the case when converting from sp classes to geoJSON.

Example

  x_coord <- c(-114.345703125, -114.345703125, -106.61132812499999, -106.61132812499999,-114.345703125)
  y_coord <- c(39.436192999314095, 43.45291889355468, 43.45291889355468, 39.436192999314095, 39.436192999314095)
  coords <- cbind(x_coord, y_coord)
  poly <- Polygon(coords)
  polys <- Polygons(list(poly), 1)
  sp_poly <- SpatialPolygons(list(polys))
  geojson_list(sp_poly, geometry = "polygon", precision = 4)

test added for precision for sp polygons works with other sp classes

@sckott
Copy link
Collaborator

sckott commented Oct 4, 2019

thanks @ChrisJones687 having a look

@sckott
Copy link
Collaborator

sckott commented Oct 4, 2019

Thanks for this, but did you run the tests that you added? It fails because you have test_that("text ..."){} instead of test_that("text ...", {})

R/zzz.r Outdated Show resolved Hide resolved
R/geojson_list.R Outdated
@@ -11,6 +11,9 @@
#' GeometryCollection.
#' @param group (character) A grouping variable to perform grouping for polygons - doesn't apply
#' for points
#' @param precision desired number of decimal places for the coordinates in the
#' geojson file. Using fewer decimal places can decrease file sizes (at the
#' cost of precision).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add here that this works up to a point, that point being the value of getOption("digits"). If you want more digits than precision allows, then fiddle with options(digits = <some number>)

@sckott
Copy link
Collaborator

sckott commented Oct 9, 2019

can you add an example or two of using the parameter?

@ChrisJones687
Copy link
Contributor Author

can you add an example or two of using the parameter?

Examples added and adjusted language on the precision argument.

@sckott sckott added this to the v0.8 milestone Oct 14, 2019
@sckott
Copy link
Collaborator

sckott commented Oct 14, 2019

thanks! a few things to fix, but i'll do that after merge

@sckott sckott merged commit 50d99de into ropensci:master Oct 14, 2019
@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants