Comments (8)
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.
from topogram.
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")
Victor
from topogram.
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.
from topogram.
Thank you.
How about Sweden?
from topogram.
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
)
from topogram.
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.
from topogram.
Would be great if in the future we can just point to some Spatial Data Frame/shapefile and have toporgRam do the rest!
from topogram.
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.
from topogram.
Related Issues (3)
- New Zealand maps HOT 8
- consider geojsonsf HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from topogram.