-
Notifications
You must be signed in to change notification settings - Fork 505
Nicer handling of spatial args #12
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
Conversation
This reverts commit 92219f89b5fa2d630e2fbab0b97df8762361b59c.
Also export pointsData generics, this is for testing
- Add data parameter to most layer functions - Reverse order of lat/lng to lng/lat in most functions - If lng and/or lat are NULL, infer spatial points from data if possible - Change how data is stored; map$x$data means the data will be serialized and sent to the client, that's bad - Add normalize.R examples, we can delete once this all shakes out
R/normalize.R
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need a fallback error message here? (If no lng/lat cars found)
Looks good! |
I often use unnecessary returns for clarity but these two are pretty egregious :)
Thanks for the feedback. |
Nicer handling of spatial args
Are there any other packages using the convention of "lng first lat second"? I thought a while on this issue again. Although lat is for the y-axis and lng for x-axis, by x first y second, the natural order for lat/lng seems to be |
@yihui I'm pretty sure this is what sp does. |
OK, I just looked at leafletjs.com and it uses the convention of lat, lng when the user provides a coordinate |
I think it would be bad to adopt a convention (y, x) that's different to all other graphics packages in R |
The question is, when you look at a map, do you think in a Cartesian coordinate system as in other R plots, or you think about latitudes/longitudes? I bet most people think about the latter, so they would not even notice they are actually using I looked at sp again, and it considers the data as |
I keep going back and forth on this as well. Geojson does lng lat. I think That said I keep typing lat lng over and over by mistake, to the point that
|
I just asked on Twitter, and apparently there is no consensus 😭 Let's just keep the order lng/lat then. Linting sounds helpful, which is also what Barry mentioned: https://twitter.com/geospacedman/status/542722245572165633 |
lng, lat
instead oflat, lng
nowNULL
to infer from data, formula evaluated against data, or direct. (You can now doleaflet(data) %>% addCircles()
)