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

Can't see stroked outlines on polygon layers #91

Closed
MikeLydeamore opened this issue Feb 28, 2023 · 6 comments
Closed

Can't see stroked outlines on polygon layers #91

MikeLydeamore opened this issue Feb 28, 2023 · 6 comments

Comments

@MikeLydeamore
Copy link

I'm trying to add a flat polygon layer, with a stroke on the outside. I can get a thin line by setting stroked = TRUE and extruded=TRUE, but I haven't managed to get a thick line, and the outline isn't really visible enough.

I have tried setting get_line_width to a large number, but it seems to have no effect.

Here is a short example showing the unexpected behaviour

library(rdeck)
library(dplyr)
library(sf)
library(absmapsdata)

shp <- sa32016 %>%
  filter(gcc_name_2016 == "Greater Melbourne")

rdeck(
  map_style = mapbox_dark(),
  # set the bounds of the map to include all of the manhattan data
  initial_bounds = st_bbox(shp),
  # add a 2 pixel buffer to each point, making it easier to hover
  picking_radius = 2
) |>
  add_polygon_layer(
    data = shp,
    get_polygon = geometry,
    filled = TRUE,
    opacity = 0.1,
    stroked = TRUE,
    get_line_color = "#663399ff"
  )
@anthonynorth
Copy link
Member

The problem is that line_width_units defaults to "meters", so your lines 1m wide. This a bad default in my opinion.

Try this

library(rdeck)
library(dplyr)
library(sf)
library(absmapsdata)

shp <- sa32016 %>%
  filter(gcc_name_2016 == "Greater Melbourne")

rdeck(
  map_style = mapbox_dark(),
  # set the bounds of the map to include all of the manhattan data
  initial_bounds = st_bbox(shp),
  # add a 2 pixel buffer to each point, making it easier to hover
  picking_radius = 2
) |>
  add_polygon_layer(
    data = shp,
    get_polygon = geometry,
    filled = TRUE,
    opacity = 0.1,
    stroked = TRUE,
    get_line_color = "#663399ff",
    line_width_units = "pixels",
  )

melb

@anthonynorth
Copy link
Member

Related #92

@MikeLydeamore
Copy link
Author

Interesting, when I run that script I don't get any outlines at all:

image

> version
               _                           
platform       aarch64-apple-darwin20      
arch           aarch64                     
os             darwin20                    
system         aarch64, darwin20           
status                                     
major          4                           
minor          1.2                         
year           2021                        
month          11                          
day            01                          
svn rev        81115                       
language       R                           
version.string R version 4.1.2 (2021-11-01)
nickname       Bird Hippie              

I also have a broken display in the RStudio Viewer, so I'm looking in the webpage. Not sure if that's connected or not, or perhaps it is an R version issue?

@MikeLydeamore
Copy link
Author

Oh never mind, this is solved with a line_width_min_pixels argument, so I guess it is related to a default zoom level or something like that.

I'll consider this one closed.

@anthonynorth
Copy link
Member

The above (#91 (comment)) should have just worked as is, because the default get_line_width = 1. line_width_min_pixels = 1 also works in this case, since you'll (likely) not get > 1 pixel for 1m lines.

@anthonynorth
Copy link
Member

I also have a broken display in the RStudio Viewer, so I'm looking in the webpage. Not sure if that's connected or not, or perhaps it is an R version issue?

If you're using a QtWebEngine version RStudio, rdeck probably won't render in the viewer. I removed legacy browser support (QtWebEngine-RStudio viewer was locked to Chrome 69) from rdeck in v0.5.1.

Rdeck renders in the Electron-RStudio viewer. I've just run the above script on the latest RStudio release for windows:
image

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

No branches or pull requests

2 participants