Skip to content

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented Dec 10, 2014

  • Most layer functions take lng, lat instead of lat, lng now
  • Layers that can take formulas now also take a data override param
  • Lots of ways to assign lng/lat values now: NULL to infer from data, formula evaluated against data, or direct. (You can now do leaflet(data) %>% addCircles())
  • Don't serialize entire data object to client

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
Copy link
Member

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)

@hadley
Copy link
Member

hadley commented Dec 10, 2014

Looks good!

I often use unnecessary returns for clarity but these
two are pretty egregious :)
@jcheng5
Copy link
Member Author

jcheng5 commented Dec 10, 2014

Thanks for the feedback.

jcheng5 added a commit that referenced this pull request Dec 10, 2014
@jcheng5 jcheng5 merged commit 9979752 into master Dec 10, 2014
@jcheng5 jcheng5 deleted the refactor/spatial-args branch December 10, 2014 07:21
@yihui
Copy link
Contributor

yihui commented Dec 10, 2014

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 lng, lat if we think on a Cartesian plane, but I guess the more natural order in English is lat, lng. Interestingly, the natural language order is lng, lat in Chinese :)

@hadley
Copy link
Member

hadley commented Dec 10, 2014

@yihui I'm pretty sure this is what sp does.

@yihui
Copy link
Contributor

yihui commented Dec 10, 2014

OK, I just looked at leafletjs.com and it uses the convention of lat, lng when the user provides a coordinate [x, y]. Personally I'm more comfortable with this.

@hadley
Copy link
Member

hadley commented Dec 10, 2014

I think it would be bad to adopt a convention (y, x) that's different to all other graphics packages in R

@yihui
Copy link
Contributor

yihui commented Dec 10, 2014

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 [y, x]. In fact, it was not until this morning that I realized latitudes were actually for the y-axis. I always thought latitudes were along the x-axis because I had been thinking of the latitude lines on the earth...

I looked at sp again, and it considers the data as [x, y] coordinates instead of latitudes/longitudes specifically. Based on the abstraction on the x-y plane, it makes sense to put x before y, but when we consider lat/lng specifically, I feel the order of function arguments is naturally lat before lng. When you click on a Google map, it also shows you the location [x, y] where x is lat and y is lng. So my slight preference would be lat before lng.

@jcheng5
Copy link
Member Author

jcheng5 commented Dec 10, 2014

I keep going back and forth on this as well. Geojson does lng lat. I think
sp, ogr, etc can theoretically work with either depending on the
proj4string but lng lat is more natural.

That said I keep typing lat lng over and over by mistake, to the point that
I was flirting with the idea of linting using deparse(substitute()).
On Dec 10, 2014 8:33 AM, "Yihui Xie" notifications@github.com wrote:

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 [y, x]. In fact, it was not
until this morning that I realized latitudes were actually for the y-axis.
I always thought latitudes were along the x-axis because I had been
thinking of the latitude lines on the earth...

I looked at sp again, and it considers the data as [x, y] coordinates
instead of latitudes/longitudes specifically. Based on the abstraction
on the x-y plane, it makes sense to put x before y, but when we consider
lat/lng specifically, I feel the order of function arguments is naturally
lat before lng. When you click on a Google map, it also shows you the
location [x, y] where x is lat and y is lng. So my slight preference
would be lat before lng.


Reply to this email directly or view it on GitHub
#12 (comment).

@yihui
Copy link
Contributor

yihui commented Dec 10, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants