Making crisp spike maps with R

Published 2023-03-12
Join me in today's tutorial as we embark on another R quest to make a crisp spike population map using the Kontur dataset.

0:00 Intro
1:23 Data source
4:35 Load packages
5:53 Download & unzip data
7:47 Load data
8:54 Plot data
9:50 Get raster size - 1st part
10:48 Bounding box explained
13:28 Get raster size - 2nd part
15:56 Rasterize
16:55 Plot raster
17:21 Raster to matrix
17:58 Color palette
19:07 Render scene
23:24 First output
24:05 Render camera
24:45 Second output
25:10 Render high-quality settings
25:40 Ligth direction
26:40 Light altitude
27:17 Mapping with rayshader
28:42 Intermezzo
28:46 Final map
29:26 Closing

Check the full code in my GitHub repo:
github.com/milos-agathon/making-crisp-spike-maps-w…

Follow my work on Instagram:
www.instagram.com/milos_makes_maps

Let's connect on Twitter:
twitter.com/milos_agathon

If you like my work, consider buying me a coffee:
www.buymeacoffee.com/milospopovic

Music credits go to:
"Sappheiros - Embrace" is under a Creative Commons license (CC BY 3.0)
@sappheiros
Music promoted by BreakingCopyright: bit.ly/embrace-song

All Comments (21)
  • @victorhm21
    This is fantastic!! Thank you for putting in the time to share this with us.
  • @Aaqib..
    I follow you on twitter and the maps and visualisations are amazing, i had no idea but that you have a YouTube channel too🤩
  • @lbarq
    Amazing. Great tutorial. I'm looking forward to your next video, as a suggestion, the forest density of a country, using rayshader package.🙂
  • @edodanilyan
    Fantastic tutorial, thank you. I am wondering how to overlay a shp file containing border and the name of the cities etc with this type of map?
  • @weitzun9691
    Hey Milos, if I want to replicate the other country, besides change the ISO 2 code (line 28) , the Lambert Projection (line 47) also need to be changed as well right ?
  • @arhamanwar3365
    Great tutorial! Amazing work. I am seeing this error when I am trying to export/render the graph with lighting. Any ideas why? Error in rayvertex::validate_mesh(mesh) : !any(is.na(normals)) is not TRUE >
  • @Geotechdev
    Thanks for the amazing work. My question est literally basic. What's the software you're using? I can't guess. Thanks for all the work
  • Hello Milos, nice Tutorial, please would this work if I want to try for the European LAU level
  • @lutzbenson
    Thanks a lot for this fantastic tutorial! I tried to adapt your code for a part of Switzerland, the canton of St.Gallen. Unfortunately, I always get the folloowing error message: Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], : unused argument (texture = TRUE) Do you have any idea what my be the reason? Is it possible that's because I used another projection? I switched the projection of the Kontur data to Swiss National System (d.pop_ch <- st_transform(d.pop_st, crs = 2056)), because I had to do some GIS analysis based on that projection.
  • @HritikaParekh
    Great video, thanks for this! However, while running "pop_sf <- get_population_data()" ie. #55 i'm getting the following error : Error: crs not found: is it missing? In addition: Warning messages: 1: In CPL_crs_from_input(x) : GDAL Error 1: PROJ: Cannot open espg 2: In CPL_crs_from_input(x) : GDAL Error 1: PROJ: proj_create: cannot expand +init=espg:24383 +type=crs Any idea how i can solve for this? Thanks in advance!
  • @tamarac3843
    Great tutorial - very comprehensive yet clear! I really appreciate the time and effort that you're putting into making these tutorials :) I've managed to create the map of Germany using your tutorial, and wanted to try my hand at making another map for France. However, when following the tutorial and I get to the 'get_population_data()' section of the code, I keep getting this error message 'Error: Path exists and overwrite is FALSE'. I'm not sure what I'm doing wrong, or what the work around is, so if you have any suggestions, then that would be great! Thanks in advance!
  • @rigocaruso
    Hi Milos! Thanks for this series of videos, I'm learning a lot of stuff. One question about this one, basically due to my little knowledge of functional programming: what are you asking R to do exactly with these two lines of code? width_ratio <- get_raster_size()[[1]] height_ratio <- get_raster_size()[[2]] I get what the get_raster_size() function does in general, but I don't get what [[1]] and [[2]] stand for. If you have a link with more information on this topic I'll be happy to take a look!
  • @stevecarufel8353
    It seems R/my computer is unable to load the very first ggplot() call - I don't have a powerful machine but I thought it would do? Does everyone have a big powerful pc here? Only have an Intel i5 8th gen, 8 gb ram and the stock graphics card... Edit : finally rendered (the first one) but needed quite some time
  • @arieldome530
    Hello may I ask about something, I always got this error message when i about to export the image. What do you think is the main problem for this? Is it on my Mac or idk, thank you for your help. Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], : unused argument (texture = TRUE)
  • @kunalbali810
    Nice tutorial. What should be crsLAEA for the Indian region?
  • @bkryasim
    Can it be applied to show refugees and IDPs in a country? Or it needs more info