GithubHelp home page GithubHelp logo

Comments (8)

pvictor avatar pvictor commented on June 19, 2024 2

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.

pvictor avatar pvictor commented on June 19, 2024 1

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

from topogram.

pvictor avatar pvictor commented on June 19, 2024

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.

duleise avatar duleise commented on June 19, 2024

Thank you.
How about Sweden?

from topogram.

pvictor avatar pvictor commented on June 19, 2024

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.

duleise avatar duleise commented on June 19, 2024

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.

popovs avatar popovs commented on June 19, 2024

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.

pvictor avatar pvictor commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.