-
Notifications
You must be signed in to change notification settings - Fork 121
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
Problem with zoom in tm_borders() #634
Comments
Hi @rafapereirabr -- it seems to be a deeper (than tmap) problem: # devtools::install_github("ipeaGIT/geobr", subdir = "r-package")
library(tmap)
library(geobr)
# download data of Brazilian states
brasil <- read_state(code_state = "all")
#> Using year 2010
#> | | | 0% | |=== | 4% | |===== | 7% | |======== | 11% | |========== | 15% | |============= | 19% | |================ | 22% | |================== | 26% | |===================== | 30% | |======================= | 33% | |========================== | 37% | |============================= | 41% | |=============================== | 44% | |================================== | 48% | |==================================== | 52% | |======================================= | 56% | |========================================= | 59% | |============================================ | 63% | |=============================================== | 67% | |================================================= | 70% | |==================================================== | 74% | |====================================================== | 78% | |========================================================= | 81% | |============================================================ | 85% | |============================================================== | 89% | |================================================================= | 93% | |=================================================================== | 96% | |======================================================================| 100%
plot(brasil) brasil3 <- subset(brasil, abbrev_state != "xx")
plot(brasil3) Created on 2022-03-09 by the reprex package (v2.0.1) |
Bounding box information seems to be off: # devtools::install_github("ipeaGIT/geobr", subdir = "r-package")
library(tmap)
library(geobr)
library(sf)
#> Linking to GEOS 3.9.2, GDAL 3.3.2, PROJ 8.2.1; sf_use_s2() is TRUE
# download data of Brazilian states
brasil <- read_state(code_state = "all")
#> Using year 2010
#> | | | 0% | |=== | 4% | |===== | 7% | |======== | 11% | |========== | 15% | |============= | 19% | |================ | 22% | |================== | 26% | |===================== | 30% | |======================= | 33% | |========================== | 37% | |============================= | 41% | |=============================== | 44% | |================================== | 48% | |==================================== | 52% | |======================================= | 56% | |========================================= | 59% | |============================================ | 63% | |=============================================== | 67% | |================================================= | 70% | |==================================================== | 74% | |====================================================== | 78% | |========================================================= | 81% | |============================================================ | 85% | |============================================================== | 89% | |================================================================= | 93% | |=================================================================== | 96% | |======================================================================| 100%
brasil3 <- subset(brasil, abbrev_state != "xx")
st_bbox(brasil)
#> xmin ymin xmax ymax
#> -66.810253 -13.693700 -59.774353 -7.969294
st_bbox(brasil3)
#> xmin ymin xmax ymax
#> -73.990450 -33.752081 -28.835944 5.271841 Created on 2022-03-09 by the reprex package (v2.0.1) |
@rafapereirabr I am just guessing, but maybe the issue is here: |
Thanks for the heads up @Nowosad . This was on the spot! (see test below). I am now wondering, though, why
|
Heads-up @rafapereirabr this is a known issue and I've been bitten by it before. I recall seeing recent discussion and maybe even development towards a fix of better data.table/sf integration but not sure if the bbox issue, which is a price you pay for waaay faster rbinding, is fixed. There are work-arounds. Keep us posted with how you get on but this is a tmap issue so I closing it here. 👍 to opening an issue on the |
Hi all. I'm trying to plot a map with
tmap
but it's showing a somewhat strange behavior. Pleasse see the reproducible example below:For some reason, this plot zooms in one specific state of Brazil. However, if I run a simple subset remove any state, the
tm_borders()
returns the correct map showing the whole country. In fact, this solution works even when I run a subset removing a state that does not existe in the data.Do you have any idea what this is happening? thanks for the help and for such a great package!
The text was updated successfully, but these errors were encountered: