dkahle / dkahle/ggmap

calc_zoom returns Inf if coordinates in a straight line

Open
#318 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
778
Forks
234
PR merge metrics
No merged PRs in 30d

Description

It seems that calc_zoom will return Inf if all the coordinates are in a straight line, both in the longitude or latitude direction. Please see below for a reproducible example.

These all fail

````
list(
a=data.frame(rbind(c(0,0),c(0,1))),
b=data.frame(rbind(c(0,0),c(1,0))),
c=data.frame(rbind(c(0,0),c(0,5))),
d=data.frame(rbind(c(0,0),c(0,1),c(0,2))),
e=data.frame(rbind(c(5,5),c(5,6)))
) %>%
map(~{make_bbox(X1,X2,data=.) %>% calc_zoom}) %>% unlist
````

These are successful
````
list(
x=data.frame(rbind(c(0,0),c(1,1))),
b=data.frame(rbind(c(0,0),c(1,0.1))),
c=data.frame(rbind(c(0,0),c(0.1,0.1)))
) %>%
map(~{make_bbox(X1,X2,data=.) %>% calc_zoom}) %>% unlist
````

I'm using ggmap 3.0.0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.