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

Only france-reg, france-reg-2016, france-dep, usa-states are available? #2

Closed
duleise opened this issue Mar 29, 2017 · 8 comments
Closed

Comments

@duleise
Copy link

duleise commented Mar 29, 2017

Any chance more regions will be included?
Thank you.

@pvictor
Copy link
Member

pvictor commented Mar 29, 2017

Yes more regions can be included ! Which one do you want ?
I can add the shape to the package like the other and I will also look if it's possible to pass geo shape as an argument.

@duleise
Copy link
Author

duleise commented Mar 29, 2017

Thank you.
How about Sweden?

@pvictor
Copy link
Member

pvictor commented Mar 30, 2017

I've integrated the first level of administrative divisions for Sweden, you can test with :

devtools::install_github("pvictor/topogRam")
library(topogRam)

# Population data
sweden_data <- data.frame(
  id = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21"),
  name = c("Östergötland", "Blekinge", "Dalarna", "Gävleborg", "Gotland", "Halland", "Jämtland", "Jönköping", "Kalmar", 
           "Kronoberg", "Norrbotten", "Orebro", "Södermanland", "Skåne", "Stockholm", "Uppsala", "Värmland", "Västerbotten", "Västernorrland", 
           "Västmanland", "Västra Götaland"),
  population = c(452105, 158453, 284531, 284586, 284586, 320333, 128673, 352735, 242301, 194628, 250570, 294941, 288097, 1324565, 2269060,
                 361373, 279334, 265881, 245572, 267629, 1671783),
  stringsAsFactors = FALSE
)

# Make a topogRam
topogRam(
  data = sweden_data,
  shape = "sweden-1",
  key_var = "population",
  geo_lab = "name",
  colors = brewer.pal("Reds", n = 3),
  origin = c(22, 60), scale = 2500
)


# Create a random variable
sweden_data$random <- sample(sweden_data$population)

# Test with two variables
topogRam(
  data = sweden_data,
  shape = "sweden-1",
  key_var = c("population", "random"),
  geo_lab = "name",
  colors = brewer.pal("Reds", n = 3),
  origin = c(22, 60), scale = 2500
)

@duleise
Copy link
Author

duleise commented Mar 31, 2017

Thank you so much. It works smoothly.
I guess the core part is the shape file you created for Sweden. I am wondering if it's possible to create it by myself? I may need deeper level, or certain regions for example.
Thank you again for you prompt response.

@pvictor
Copy link
Member

pvictor commented Apr 2, 2017

You're welcome! You're right the core part is the shape file, it's in fact a topojson; The step to create it are a little manual for the moment, i'll look to automatize and describe the process.

@popovs
Copy link

popovs commented Feb 2, 2018

Would be great if in the future we can just point to some Spatial Data Frame/shapefile and have toporgRam do the rest!

@pvictor
Copy link
Member

pvictor commented Feb 12, 2018

Yes it would be top, what's complicated is that topogram.js needs topojson to work, I'll try to find some time to see if a standalone R solution exists. And I'll migrate to D3v4 too.

@pvictor
Copy link
Member

pvictor commented Oct 4, 2018

This works now for any sf objects, try this (or with any country) for example :

library(rnaturalearth)
library(topogram)

sweden <- ne_states(country = "sweden", returnclass = "sf")
sweden$foo <- floor(runif(nrow(sweden), 500, 5000))

topogram(sweden, "foo")

image

Victor

@pvictor pvictor closed this as completed Oct 4, 2018
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

3 participants