choropleth

Interactive Choropleth in R of Sweden

好久不见. 提交于 2019-12-08 03:42:28
I'm trying to develop an interactive choropleth in a Shiny application in R. I've tried with plotly, gVis and rCharts, but still without any luck. I need to visualise it for Sweden right now, but I probably need it for other countries as well later on. This is what I have so far for gvisGeoMap: polygons <- readOGR("/ggshape", layer="SWE_adm1") polygons <- fortify(polygons, region="ID_1") data.poly <- as.data.frame(polygons) data.poly <- data.poly[,c(1,2)] data.poly.final <- data.frame(locationvar = paste(data.poly[,2],data.poly[,1], sep = ":"), numvar=1, hovervar="test") data.poly.final

python plotly: how to make a choropleth map with a slider (access grid data issue)

南楼画角 提交于 2019-12-07 17:41:00
问题 I want to draw a choropleth world map with a slider for the year values. It would be a combination of the "Choropleth Map" and the "Adding Sliders to Animations" (https://plot.ly/python/). First I searched plotly's community forum and the web for an example of a plotly choropleth map with grid data or a slider without success. While I managed to replicate the slider animation example with my data (see jupyter notebook link below), adapting the choropleth code to access grid data with a slider

plotly choropleth map: display country names

自古美人都是妖i 提交于 2019-12-07 13:00:35
问题 Consider the following R code to produce a choropleth map in plotly: #devtools::install_github("ropensci/plotly") library(plotly) df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv') # light grey boundaries l <- list(color = toRGB("grey"), width = 0.5) # specify map projection/options g <- list( showframe = FALSE, showcoastlines = FALSE, projection = list(type = 'Mercator') ) plot_ly(df, z = GDP..BILLIONS., text = COUNTRY, locations = CODE,

Is there a way that I can manually control the thresholds between various range on choroplethr?

丶灬走出姿态 提交于 2019-12-06 16:43:20
I would like to be able to manually control the thresholds between population ranges on choroplethr package. library(choroplethr) data(df_pop_county) data(continental_us_states) county_choropleth(df_pop_county, state_zoom = continental_us_states) You can use cut to create the custom breaks: # rename the original "value" column if you don't want to write over it names(df_pop_county) <- c("region", "original_value") # define the breaks you want df_pop_county$value <- cut(df_pop_county[["original_value"]], breaks = c(0, 1e4, 5e4, 1e5, 5e5, 1e6, 1e7)) # if you want custom labels to go along with

When should I use geom_map?

℡╲_俬逩灬. 提交于 2019-12-06 02:59:32
I'm making a choropleth map with added points in ggplot. So, following the last example of the geom_map help docs I came up with this: require(ggplot2) require(maps) set.seed(47) county_map <- map_data("county", "washington") names(county_map)[5:6] <- c("state", "id") countyData <- data.frame(id = unique(county_map$id), value = rnorm(39)) map1 <- ggplot(countyData, aes(map_id = id)) + geom_map(aes(fill = value), map = county_map, colour = "black") + coord_map() + expand_limits(x = county_map$long, y = county_map$lat) print(map1) which works great for the choropleth map. (Aside that I'm

plotly choropleth map: display country names

风流意气都作罢 提交于 2019-12-05 21:49:08
Consider the following R code to produce a choropleth map in plotly: #devtools::install_github("ropensci/plotly") library(plotly) df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv') # light grey boundaries l <- list(color = toRGB("grey"), width = 0.5) # specify map projection/options g <- list( showframe = FALSE, showcoastlines = FALSE, projection = list(type = 'Mercator') ) plot_ly(df, z = GDP..BILLIONS., text = COUNTRY, locations = CODE, type = 'choropleth', color = GDP..BILLIONS., colors = 'Blues', marker = list(line = l), colorbar = list

python plotly: how to make a choropleth map with a slider (access grid data issue)

筅森魡賤 提交于 2019-12-05 21:31:25
I want to draw a choropleth world map with a slider for the year values. It would be a combination of the "Choropleth Map" and the "Adding Sliders to Animations" ( https://plot.ly/python/ ). First I searched plotly's community forum and the web for an example of a plotly choropleth map with grid data or a slider without success. While I managed to replicate the slider animation example with my data (see jupyter notebook link below), adapting the choropleth code to access grid data with a slider does not seem to work. In contrast to a regular map (like in example one), data is not loaded from a

Choropleth map using folium and pandas

徘徊边缘 提交于 2019-12-05 18:53:41
问题 I am using folium to create a choropleth map of a set of countries. I am following the documentation. However. for some reason the map doesn't show any shades. I am using the world geojson from natural earth (see the gist). My dataframe looks like: >>> spatial_scores.head() Out[1]: id Country Score PER Peru 2.810300 HND Honduras 2.734521 GUF French Guiana 2.730886 SLV El Salvador 2.473134 CRI Costa Rica 2.454963 The world geojson looks like: >>> world_json['features'][0]['id'] Out [2]: u'AFG'

Python: how to create a choropleth map out of a shapefile of Canada?

天大地大妈咪最大 提交于 2019-12-04 23:12:25
My goal here is to create a choropleth map of Canada in Python. Suppose I have a dictionary with values referring to each Canadian province/territory: myvalues={'Alberta': 1.0, 'British Columbia': 2.0, 'Manitoba': 3.0, 'New Brunswick': 4.0, 'Newfoundland and Labrador': 5.0, 'Northwest Territories': 6.0, 'Nova Scotia': 7.0, 'Nunavut': 8.0, 'Ontario': 9.0, 'Prince Edward Island': 10.0, 'Quebec': 11.0, 'Saskatchewan': 12.0, 'Yukon': 13.0} Now I want to color each province based on the corresponding value in myvalues , using a continuous colormap (e.g., shades of red). How to do that? So far I

Python - Folium Choropleth Map - colors incorrect

与世无争的帅哥 提交于 2019-12-04 21:26:10
My problem is that suburbs are not displaying the correct color on the Folium map. For example, Dandenong and Frankston should be shaded with the darkest color as they have the highest count in the dataframe, but they are shaded with a lighter color. The dataframe is missing some suburbs. Those suburbs are being colored with the darkest color. Another problem is the csv has all suburbs in UPPERCASE but the geojson has a mixture of cases such as "Frankston", "St Kilda", or "McKinnon". It would be helpful if the choropleth code didn't care about case. I can change the text in the dataframe to