Rayshader Tutorial-Florida Population Density

Поделиться
HTML-код
  • Опубликовано: 13 июл 2024
  • This is a live-coding tutorial that walks through how to create a 3D population density map in R using the rayshader package. The example uses Kontur Population data for the state of Florida.
    Code from this tutorial is available here: github.com/Pecners/kontur_ray...
    NOTE: Before starting, I recommend you install the latest dev versions of rayshader and rayrender to avoid an error that many people are encountering when coding along with this video. Install with the following code:
    remotes::install_github("github.com/tylermorganwall/ra...")
    remotes::install_github("github.com/tylermorganwall/ra...")
    This is the error that is thrown: "Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], : unused argument (texture = TRUE)"

Комментарии • 168

  • @DataOperationsandResearch
    @DataOperationsandResearch Год назад +8

    Hello everyone. If you guys are working on Windows with R 4.2 and the Rstudio crashes/terminates when you run
    mat |>
    height_shade(texture = texture) |>
    plot_3d(heightmap = mat,
    zscale = 100
    )
    Then you should use solid = FALSE in the above function and Rstudio would not terminate. So, use the function
    mat |>
    height_shade(texture = texture) |>
    plot_3d(heightmap = mat,
    zscale = 100,
    solid = FALSE,
    )
    This problem could be specific to operating system and/or Rstudio/R version. But both I and my colleague faced this issue and it was a working fix.
    Lastly, great work @Spencer Schien. Wonderful video, keep up the good work.

  • @camilaberger2980
    @camilaberger2980 Год назад

    You are amazing, great project!!!! And thank you to share your knowledge

  • @alessandroippoliti1523
    @alessandroippoliti1523 Год назад +7

    Great tutorial, although not exactly for beginners as others have pointed out. But I was able to generate maps in a couple of days, so awesome!! I would love a video explaining the file formats etc.. to be able to map cities and districts as well. Great work anyways

    • @MrPecners
      @MrPecners  Год назад

      Glad you got it to work!

  • @nikhilbaisla1474
    @nikhilbaisla1474 Год назад +1

    Was looking for something like this for soooooooo long
    Thanks a lot🙏

    • @MrPecners
      @MrPecners  Год назад

      You bet!

    • @rajshekarreddy5358
      @rajshekarreddy5358 Год назад

      Hey nikhil, please help me, I'm unable to load the data into rstudio. I've downloaded the data from the website.

  • @sayedrohullahkazemi6157
    @sayedrohullahkazemi6157 8 месяцев назад +1

    Amazing work, thank you.

  • @kevinalexis9886
    @kevinalexis9886 Год назад +1

    This is great thanks for sharing!

  • @naanel
    @naanel Год назад +1

    I love it ! Thank you so much

  • @TomWalsh313
    @TomWalsh313 Год назад

    Amazing video thanks so much! One suggestion would be to demonstrate how to add labels to different cities

  • @johneagle4384
    @johneagle4384 9 месяцев назад

    Wow. Cool Stuff. Impressive. Thank you.

  • @pdcoronado
    @pdcoronado Год назад +1

    Esta genial, saludos desde Ecuador.

  • @noclips.
    @noclips. Год назад +8

    After seeing your reddit post, I decided to give this a go as a chance to learn something new. This is my first foray into R coming from C#. Really great job on the tutorial! I do have some notes from a complete beginner:
    1:25 Maybe show how you setup the intial project real quick
    5:53 Mention that you used ctrl+shift+N to create a new script. It would help a lot to mention any hotkeys for viewers new to this IDE.
    6:10 All of the packages used must be installed first. It would be helpful to cover how to easily do this for at least the first one.
    6:16 Mention that you use ctrl+enter to quickly run your line and maybe a quick 15 sec overview of how the script, console, and environment windows work together.
    27:54 I'm stuck here on st_rasterize getting an error about units cannot be mixed and I can't figure out the fix. It's late so I'll continue troubleshooting tomorrow.

    • @Maria-ez1mx
      @Maria-ez1mx Год назад +4

      I solved the st_rasterize by including this in my code: library(units)
      units_options(allow_mixed = TRUE)

    • @noclips.
      @noclips. Год назад +1

      @@Maria-ez1mx Thanks that helped, but it just led me to another error about the values argument missing. I ended up hardcoding the nx & ny to get through it.
      I'm so close now but can't get past an error in render_highquality: Error in rayrender::obj_model unused argument (texture=TRUE). Did you experience something similar?

    • @MrPecners
      @MrPecners  Год назад +3

      Thanks for your comments and your feedback! Ah, that texture=TRUE argument, I haven't tracked down exactly why that error is thrown, but I've heard from others that installing the most recent dev version of the package solves it. Install that with remotes::install_github("tylermorganwall/rayshader"). You might need to update the rayrender package as well (which rayshader uses behind the scenes), install that with remotes::install_github("tylermorganwall/rayrender"). You need the remotes package there, so you might have to download that as well: install.packages("remotes").

    • @tusharpatni4514
      @tusharpatni4514 Год назад +1

      ​@@MrPecners​Thank you for the suggestion! I had the same error.

    • @miaocai2078
      @miaocai2078 Год назад +1

      @@MrPecners Thanks for the solution. Updating rayshader and rayrender works for me. I like your videos and I much prefer following your code line-by-line in your youtube videos than reading those lengthy blog posts. Look forward to more videos like this, I'm loving it!

  • @Maria-ez1mx
    @Maria-ez1mx Год назад +3

    Love this tutorial - thank you so much! Have you got any code examples where you start with points (e.g., locations of shops with longitude / latitude, essentially multipoints), convert them to polygons (e.g., density of shops) and then intersect? Or would you have any idea how to approach this? Have been trying st_join and st_intersection, but no luck.

    • @MrPecners
      @MrPecners  Год назад +1

      Glad you liked it! My first thought is that you could bucket your points by either some pre-defined polygons (e.g. census tracts, city limits, neighborhoods), or you could define your own polygons. You can define your own for a given area using the sf::st_make_grid() function, which allows you to create a polygon grid of either rectangles or hexagons. Whichever polygon route you choose, you can then do a join (I think intersection would work too) of the points and polygons, and then group by the polygon and summarize the total count of points.
      I think the closest example I have of this that I can share is this script (github.com/Pecners/snowy_owls_wi/blob/master/R/so_sightings_wi.R), specifically lines 49:55.
      Hope this helps!

  • @user-fp6ng5fx6p
    @user-fp6ng5fx6p Год назад

    Hi Spencer,
    Thanks a lot for the great video and template code. I ran a few examples and that worked fine. Of course, always time-consuming to find the ideal angles / lighting and resolutions while avoiding crashes.
    I would have a question related to the height and width. You mention that the unit is in meters based on st_crs(data), but I have some doubts. For Switzerland I get height = 325'262.5m, but Switzerland is only roughly 220km North-South. Could you please clarify?

  • @konigvlogs
    @konigvlogs Год назад

    Hi! Great tutorial! Woult it possible to do a similar map but with elevation data? Thanks

  • @Ponkkis71
    @Ponkkis71 Год назад

    Thanks for the amazing guide 😊 Any idea why my matrix is appearing hollow when it hits the boundaries of the area?

  • @eylonshahar2979
    @eylonshahar2979 Год назад

    Thank you very much!
    I'm trying to make a map of Israel but I'm having some difficulties. First :
    Warning in matrix(israel_rast, nrow = floor(size * w_ratio), ncol = floor(size * :
    data length [30] is not a sub-multiple or multiple of the number of rows [994]
    and then:
    > mat |>
    + height_shade() |>
    + plot_3d(heightmap = mat)
    Error: vector memory exhausted (limit reached?)
    What should i do?

  • @yibrilmassip3429
    @yibrilmassip3429 Год назад

    Hi, Spencer, first, thanks for your time teaching us to do these amazing maps!
    I would like to know if there is a way to add state boundaries to any map? i saw your Oregon map, and at the final image you have in your GitHub page, it shows the boundaries but i walked through the scripts and couldnt find the line.
    If you can show us how to do it we will apreciated! Again thanks for your incredible work!

    • @MrPecners
      @MrPecners  Год назад +2

      Thanks for your kind words! Yes, there are a couple ways to do this, but my preferred method is to simulate data to match the boundaries. I take the state boundary polygon, cast it to a multilinestring, then buffer around it so it will be large enough to show up on the final map, give it a dummie population of 1, then use bind_rows() to add to data. See lines 38-52 of that Oregon render script: github.com/Pecners/rayshader_portraits/blob/main/R/portraits/oregon/render_graphic.R

  • @philippsidler2408
    @philippsidler2408 Год назад

    Awesome 👏🏻 thanks. Could you do at some point a tutorial how to additionally add mountain reliefs? Living in Switzerland so that would be pretty cool

    • @MrPecners
      @MrPecners  Год назад +1

      Encoding both population density and elevation to the height axis can make it very hard to interpret. Here's one example I know of: twitter.com/researchremora/status/1630318714343047171

    • @philippsidler2408
      @philippsidler2408 Год назад

      🙏🏻

  • @IrakliKavtaradzepsyche
    @IrakliKavtaradzepsyche Год назад

    Thank you so much for this tuytorial. I was waiting for it for a long time actually.
    One genuine question though, why do you truggle annotate text in R when you can do that so easily in vector editing software?

    • @MrPecners
      @MrPecners  Год назад +1

      Good question--I prefer having everything scripted out so that it's easier to reproduce, plus it keeps everything contained within R.

    • @IrakliKavtaradzepsyche
      @IrakliKavtaradzepsyche Год назад

      @@MrPecners I see

  • @pujaadityawinata
    @pujaadityawinata Год назад +1

    What an amazing visualization! This inspired me to make my own visualization. Everything is going well when i working with maps that have width > height, i can get the visualization. But when i'm working with maps that have height > width, i got an error in
    ph_rast

  • @lbarq
    @lbarq Год назад

    Awesome content. How would you label/identify with text on the map the cities of florida? Thanks

    • @MrPecners
      @MrPecners  Год назад +1

      There technically is a way to do this with Rayshader, but I prefer to do labeling post-render. I use imagemagick (through the R {magick} package) to add text annotations, and I would do the same to add those labels. That requires manual label placement, though...

  • @MarinaMatiss
    @MarinaMatiss Год назад +3

    Hi Spencer, first of all, thanks a million for your tutorial! I can see how much effort and time you have put into it and it's very nice of you to share it.
    I do have 2 questions though, if I may.
    1. We were using library here, tigris, that is used to basically lay the coordinates over the states of the US. Is there such a library for other countries like Japan, Spain or Germany? Where can we find this kind of information?
    2. I tried to run this code also for another state, California, but got an interesting error that I don't fully understand and don't know how to fix:
    the error pops up when running this piece of code:
    size

    • @nishanthhebbar4888
      @nishanthhebbar4888 Год назад

      I'm getting the same error

    • @MrPecners
      @MrPecners  Год назад +3

      Hi there,
      Thanks for your message, and your kind words. For your first question, you can use raster::getData() as described in another comment by @rajatlohia. I also show how to do that in my newest video.
      For your second question about the error, @rajatlohia figured that one out too: the issue is that one of those values is being defined as a units object. Try wrapping both w_ratio and h_ratio in as.numeric(), that should solve it for you.
      raster

    • @MarinaMatiss
      @MarinaMatiss Год назад

      @@MrPecners thank you so much ;)

  • @mattzarek9884
    @mattzarek9884 Год назад

    great tutorial!
    I'm having an issue with my rgl window. whenever I increase the matrix size, even above 8 MB, the rgl window remains blank and I get the folllowing warning message :
    1: In rgl.primitive0(type = "triangles", x = c(-279.5, -278.5, -277.5, :
    RGL: GL Library : Maximum texture size of 1024x1024 exceeded
    I've searched for other solutions online and besides updating the packages don't see any fixes
    The high quality render doesn't generate anything if the rgl window doesn't work.
    I have the most updated versions of rayshader, rgl, rayrender. I'm running windows x64 with 8GB RAM.
    Any ideas?

  • @keshavchadha80
    @keshavchadha80 Год назад

    Hello Spencer, like Tigris package is specifically for US Shapefile. Can you help me with the package solely for Indian shapefile?

  • @huangyan-chen724
    @huangyan-chen724 Год назад

    I really appreciate your work and the tutorial. It is amazing! I have follow your tutorial, however when I run plot_3d() my rgl device windows does not show any thing and the console do not show any error messages. I'm curious about what might be the reason behind this.

    • @MrPecners
      @MrPecners  Год назад

      Hmm I'm not sure offhand. I think I saw you post something on Twitter though, did you figure this out?

  • @tomcrown_adventure
    @tomcrown_adventure Год назад +1

    Hi Spencer, great video, super cool :) Do you know how can we specify the visualization to a specific area (e.g. using coordinates), in order to create this visual for a specific region of Florida?

    • @MrPecners
      @MrPecners  Год назад

      Thanks for the kind words! Yes, it depends a bit on what kind of coordinates, though. Do you mean you have points, and you want to show a radius around that point? Or do you have coordinates that represent a boundary polygon? What's the format of your data?

    • @tomcrown_adventure
      @tomcrown_adventure Год назад

      @@MrPecnersAppreciate the reply! I'm trying to do the exact same for Portugal. Yet the original data from kontur includes tiny Portuguese islands in the distant Atlantic. I would simply like to remove these from the visualization and do only for the continental land :)

    • @MrPecners
      @MrPecners  Год назад +1

      Ah I see. I think the easiest way would be to find a polygon of just mainland Portugal, and then you could use that to mask the data as I did with Florida. I know the {rnaturalearth} R package makes available country boundary data, e.g. the code below will give you low-res boundaries for mainland Portugal.
      por
      st_as_sf() |>
      filter(admin == "Portugal")
      # Plot to see the polygon
      por |>
      ggplot() +
      geom_sf()

    • @tomcrown_adventure
      @tomcrown_adventure Год назад +1

      @@MrPecners Thank you so much! Legend!

  • @pauguarque4927
    @pauguarque4927 Год назад

    Hi Spencer! Thank you so much for this really complete tutorial! I'm a beginner using R (used to work with GIS programs), and I'm getting stuck at the render_highquality function. It displays a message like this: Error in rayrender: unused argument (texture = TRUE). I replicate exactly your process but it's no working. Do you know what could be the problem? Thank you for this content!!!

    • @MrPecners
      @MrPecners  Год назад +1

      Installing the most recent dev versions of the packages should solve that error. Install that with:
      remotes::install_github("tylermorganwall/rayshader")
      remotes::install_github("tylermorganwall/rayrender")
      You need the remotes package there, so you might have to download that as well: install.packages("remotes"). Be sure to restart your session after installing.

  • @ketevanikapanadze7476
    @ketevanikapanadze7476 Год назад

    Thank you so much! Amazing content. Your code works perfectly on my windows environment but could not finalise on my Mac. At the last point when I try to visualise and save the output I am getting the following error, I tried literally everything but could not succeed. Any ideas/suggestions? Thanks!
    Error in render_highquality(filename = outfile, interactive = FALSE, lightdirection = 280, :
    No rgl window currently open.

  • @la_jeunesse1
    @la_jeunesse1 Год назад

    > florida_rast

  • @merzougahmed4248
    @merzougahmed4248 Год назад

    Thank you so much. I am taking the approach for applications in the oil and gas industry. Could you please show me how to keep the contour of the state map plotted? thanks

    • @MrPecners
      @MrPecners  Год назад

      Very cool! Here's an example script that you can reference to achieve that, see lines 41-53: github.com/Pecners/rayshader_portraits/blob/main/R/portraits/montana/render_graphic.R

  • @burakt
    @burakt Год назад

    I processed the Island of Guam and I encountered this error message ---> Error in c.units(x = nx[[1L]], y = ny[[1L]]) :
    units are not convertible, and cannot be mixed; try setting units_options(allow_mixed = TRUE)? In addition: Warning message: attribute variables are assumed to be spatially constant throughout all geometries
    and also in the values area h_ratio = 1 gives the value.

  • @RoshniAgarwal-lp2fv
    @RoshniAgarwal-lp2fv 9 месяцев назад

    the states function we use from tigris package only loads the states of USA. is there any similar package for India? or how do we go about it while plotting the map of India?

  • @ozmenmedine
    @ozmenmedine 7 месяцев назад

    Hi Spencer!
    Thank you very much for your amazing tutorial! I would like to try this. However, I need your help :) In the beginning, you downloaded the states with "tigris" package, but as I understand this is special for the USA. So, how can I download it to Turkey's states? Could you help me, please? Because I am a beginner at this.. Many thanks..
    Medine

    • @MrPecners
      @MrPecners  7 месяцев назад +1

      Hi Medine, thanks for your message! You can use the {geodata} package. For instance, here's some code to get you started:
      turkey st_as_sf()

  • @alexvm8352
    @alexvm8352 4 месяца назад

    What’s the difference between the matrix size and the high quality render size(width/height)?

  • @NurudeenJimoh-jz2um
    @NurudeenJimoh-jz2um Год назад +1

    Great tutorial. On downloading the population data off Kontur, the file had a file extension of " .gpkg.gz " instead of " .gpkg ". So, I renamed the file ensuring the file extension was "gpkg". Trying to use st_read function to read returns this error prompt "Error: Cannot open "C:\Users\Downloads\3D visualization on R\kontur_population_NG_20220630.gpkg"; The source could be corrupt or not supported. See `st_drivers()` for a list of supported formats." What could possible be wrong?

    • @MrPecners
      @MrPecners  Год назад +1

      Ah I didn’t say this in the video, but what you download is a zipped file, and you need to unzip it. Right click on it, and you should have the option to unzip. I would download again in your case and start over since you edited the file.

  • @pivotai525
    @pivotai525 Год назад

    Amazing tutorial, thank you!! Do you know whether we can do similar thing on Python? If yes, which library? I am searching but not be able to find one, thank you again!

    • @MrPecners
      @MrPecners  Год назад +1

      I'm not sure there's a python library that does this. I've seen people process data with python, but then they turn to Blender, Aerialod, rayshader, or similar to create the faux 3D graphics.

    • @pivotai525
      @pivotai525 Год назад

      @@MrPecners Thank you very much for information!

  • @maheerdhruba7925
    @maheerdhruba7925 Год назад

    Hello Spencer,
    First of all great work done here.
    I have successfully rendered a 3D population density map of my country (Bangladesh) but now I would like to add two things:
    1. Add the administrative boundaries to the whole map.
    2. I have used a custom color gradient containing 4 colors, (green to red), to show the height of the plots. Now I would like to add a legend in the render so that it can show the population density range of the map according to the color gradient. Is it possible and how can I achieve this?
    Thanks in advance!!

    • @MrPecners
      @MrPecners  Год назад

      Hi Maheer,
      There are a couple ways to add boundaries, but my preferred method is to simulate data to match the boundaries. I take the state boundary polygon, cast it to a multilinestring, then buffer around it so it will be large enough to show up on the final map, give it a dummie population of 1, then use bind_rows() to add to data. See lines 38-52 of my Oregon render script: github.com/Pecners/rayshader_portraits/blob/main/R/portraits/oregon/render_graphic.R
      For the legend, that's a bit more complicated. I've done this where I simulate data to create a legend, but I've never really been happy with it, so I remove it on my final render. I've also done it where I create a legend in normal ggplot, then extract it as an image and then add it to the rendered map after the fact. In this case, it isn't rendered in 3D, but that can make it easier to position on your final map because you don't have to worry about shadows or perspective. You can browse my code in this repo to see an example: github.com/Pecners/great_lakes_bath.

  • @konstantinosiliakis8290
    @konstantinosiliakis8290 10 месяцев назад

    can we put some gpu acceleration on this? my cpu is dying

  • @karytsi
    @karytsi Год назад +1

    when executing:
    mat |>
    height_shade(texture = texture)|>
    plot_3d(heightmap = mat,
    zscale = 80,
    solid = FALSE,
    shadowdepth = 0)
    I get this:
    Warning messages:
    1: 'rgl.surface' is deprecated.
    Use 'surface3d' instead.
    See help("Deprecated")
    2: 'rgl.viewpoint' is deprecated.
    Use 'view3d' instead.
    See help("Deprecated")
    3: 'rgl.triangles' is deprecated.
    Use 'triangles3d' instead.
    See help("Deprecated")
    have R 4.2.3 installed... and remotes rayshader...
    any ideas?

  • @SyarmineS
    @SyarmineS 4 месяца назад

    Been doing this and at only at 58:24 you just mentioned you are on Macbook Pro. hahaha

  • @rajshekarreddy5358
    @rajshekarreddy5358 Год назад

    Please help me, I'm unable to load the data after downloading into Rstudio.

  • @sharmahitanshu
    @sharmahitanshu Год назад

    I getting issue with rgl package, did anyone else experience this issue it says: rgl.viewpoint is deprecated!!

  • @elenasynanovic
    @elenasynanovic Год назад +1

    Good day, Dear Spenser. Yes, I am totally new in RStudio and really struggling to add the kontur data to files... I know that is a shame, but this is where I stuck and can't go forward. I saw already tens of videos how to import, but it does not work for this type of file. Would appreciate your kind help. Thank you.

    • @MrPecners
      @MrPecners  Год назад

      What exactly is the issue you are encountering? Have you tried running the script from the example, i.e. st_read(...)? This tutorial is not exactly entry level, you might want to get familiar with the basics first.

    • @kingastryszowska-hill1648
      @kingastryszowska-hill1648 Год назад

      I was having an issue with this too (that is not addressed by the video). The geopackage is stored in a zipped format with a .gz extension. You need to unzip it first using 7-zip

  • @faraazali9589
    @faraazali9589 Год назад

    Hi Spencer, great tutorial.
    Im getting the following error on Win 11:
    mat |>
    + height_shade(texture=texture) |>
    + plot_3d(heightmap = mat,
    + zscale = 6,
    + background = "#fff8f2",
    + solid="FALSE",
    + shadowdepth=0
    + )
    Error in solid && !triangulate : invalid 'x' type in 'x && y'
    In addition: Warning messages:
    1: 'rgl.surface' is deprecated.
    Use 'surface3d' instead.
    See help("Deprecated")
    2: 'rgl.viewpoint' is deprecated.
    Use 'view3d' instead.
    See help("Deprecated")

  • @miaocai2078
    @miaocai2078 Год назад

    Hi Spencer, is it possible to add the geographical boundary for Florida using sf polygons in the plot?

    • @MrPecners
      @MrPecners  Год назад

      Yep, you can do that. I think you have two options. First, you could use rayshader::add_overlay() to add lines to your plot. I haven't done much with this technique, but you can read about it here: www.tylermw.com/adding-open-street-map-data-to-rayshader-maps-in-r/.
      One drawback in my opinion of that technique is that it doesn't necessarily blend as well with the rest of the map. A more involved technique that I have used that does blend well is to take your boundary polygon, cast it to a MULTILINESTRING with sf::st_cast(), buffer it a bit with sf::st_buffer() so that it's large enough to show up on map, then join it with the other data (i.e. here it would be the Kontur Population data), then set a standard height value for it to be plotted along with the other data. Then you can combine this simulated data with the population data by using bind_rows().
      Lines 45:49 of the script below is one example of where I used this technique to create gridlines that are plotted at a height of 100.
      github.com/Pecners/rayshader_portraits/blob/main/R/portraits/colorado_river/render_graphic.R.

    • @miaocai2078
      @miaocai2078 Год назад +1

      @@MrPecners Great! Thanks for the suggestions! Looking forward to more video tutorials from you!

  • @user-uv5rp8fw4b
    @user-uv5rp8fw4b Год назад

    Reading (data

  • @IrakliKavtaradzepsyche
    @IrakliKavtaradzepsyche Год назад

    Thank you again for the tutorial!
    For some reason the shadow in my case is not blurred nicely as it is in your example. It is a direct grey dot-like shadows beneath the bins. What might be the reason, do you know? Thank you in advance

    • @IrakliKavtaradzepsyche
      @IrakliKavtaradzepsyche Год назад

      I mean after removing the solid layer

    • @MrPecners
      @MrPecners  Год назад +1

      Do you mean before doing render_highquality()? If so, that’s normal, the high quality render will look better.
      If you mean it looks like that in the final high quality render, then I would check the angle of your light sources. It’s hard to say for sure based on this description, though.

    • @IrakliKavtaradzepsyche
      @IrakliKavtaradzepsyche Год назад +1

      @@MrPecners thank you. It's before render_highquality.
      Though now I'm stuck on this error:
      Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], :
      unused argument (texture = TRUE)
      tried what you and others suggested for the solution but nothing worked.

    • @IrakliKavtaradzepsyche
      @IrakliKavtaradzepsyche Год назад

      There's nothing that can't be solved by restarting R I guess. The problem's gone.

    • @yibrilmassip3429
      @yibrilmassip3429 Год назад

      @@IrakliKavtaradzepsyche Im just having the same error here, tried to restart R but it didnt work...
      Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], :
      unused argument (texture = TRUE)
      what should i try?

  • @ahmadnadeem870
    @ahmadnadeem870 Год назад

    Amazing tutorial, i am unable to install said packeges from GitHub, getting error while rendering High quality picture.

    • @MrPecners
      @MrPecners  Год назад

      What do you mean you are unable to install packages from GitHub? What error is being thrown? You need to be able to install from GitHub to complete the tutorial.

  • @nevinthomas5130
    @nevinthomas5130 Год назад

    Hi there, I have just started the tutorial and noticed that the memory usage increases to 6GB or more when reading the data.
    Is it necessary to have a good CPU and RAM for this tutorial? (my system specs: i5, 4 cores, 16GB RAM.)

    • @MrPecners
      @MrPecners  Год назад +1

      You will probably struggle to complete the tutorial doing everything the same as I do because it is pretty memory intensive. You should be able to get through it by keeping everything smaller and lower resolution.

    • @nevinthomas5130
      @nevinthomas5130 Год назад

      @@MrPecners Thanks for the reply

  • @diegoplata8835
    @diegoplata8835 Год назад

    Spencer, thanks for the great video!
    I have a problem I hope you can help me with. Everything is running fine no errors but after the render_highquality() step mi .png file is completely black with three white dots in it and I don't know what is happening because my plot 3d is rendering correctly. I've searched stack overflow and other websites but no luck getting my image right. I am working with GADM data that is the only thing different from my script to yours.

    • @MrPecners
      @MrPecners  Год назад

      Can you share the full code of your render_highquality() call?

    • @diegoplata8835
      @diegoplata8835 Год назад

      @@MrPecners yes, this is my repo script with the call is ags_obj and in there you can find also the exported png in the imgs directory

    • @diegoplata8835
      @diegoplata8835 Год назад

      @@MrPecners render_highquality(
      filename = png_outfile
      ) this is how I am calling the function my gh profile is DPLATA and I have a repository called rayshader_maps you can look at the complete code there and also look for the exported png

    • @diegoplata8835
      @diegoplata8835 Год назад

      @@MrPecners UPDATE: if I plot and render florida information same way you did it is also exporting black image I opened a question in stack overflow with the following title render-highquality-from-rayshader-r-package-only-rendering-black-png-image and a discussion in rayshader gh repo render_highquality only rendering black .png image because I don't know how to proceed. Any help would be appreciated! :D

    • @diegoplata8835
      @diegoplata8835 Год назад

      @@MrPecners UPDATE: imgs render correctly titles but still no luck making the render as in the video

  • @arieldome530
    @arieldome530 Год назад

    Hello can you help me how to correct this error?

    Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], :
    unused argument (texture = TRUE)

    • @lcsl5605
      @lcsl5605 Год назад

      Same problem here. I updated rayrender and rayshader

  • @kevinalexis9886
    @kevinalexis9886 Год назад +3

    Can you do a tutorial for a Country such as Italy for example?

    • @philippsidler2408
      @philippsidler2408 Год назад

      Yeah that would be awesome. Trying it for Switzerland but don’t know how to get the cantons (states) for it like you did in the tutorial.
      What would be the command if I would like not a single state but the whole country (Switzerland). It’s a small country so shouldn’t be a problem data wise.

    • @abelimitless
      @abelimitless Год назад

      @@philippsidler2408 yeah doing a class project in Tripoli Libya and definetly hard to extract unlike the states

    • @siddharthpetare4697
      @siddharthpetare4697 Год назад

      @@philippsidler2408download shapefiles for Switzerland and follow the same procedure. Use st_read to read shapefile.

  • @shaikhahmedbd
    @shaikhahmedbd Год назад

    I can't render in high quality. Tried after updating rayshader & rayrender, still didn't work!
    > render_highquality(
    + filename = "images/test_plot.png"
    + )
    Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], :
    unused argument (texture = TRUE)

  • @MN-ly9mw
    @MN-ly9mw 9 месяцев назад

    Can these be done on Python? I have started to learn Python. Again learning a new language might not be possible for me at this point in life 😢

    • @MrPecners
      @MrPecners  9 месяцев назад

      I would guess there’s a way to do this with python, but I don’t know exactly what libraries to use. Rayshader leverages OpenGL, so maybe some python libraries that utilize that tool would be a place to look?

  • @karytsi
    @karytsi Год назад +2

    Am trying your code, but I'm getting error in render_highquality....
    > render_highquality()
    Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], :
    unused argument (texture = TRUE)
    Any ideas? Have installed and updated packages...

    • @MrPecners
      @MrPecners  Год назад +2

      Install the dev versions of rayshader and rayrender packages with remotes::install_github("tylermorganwall/rayshader"), remotes::install_github("tylermorganwall/rayrender"). You need the remotes package there, so you might have to download that as well: install.packages("remotes"). Restart your session after install, etc.

    • @karytsi
      @karytsi Год назад

      @@MrPecners OK! Got it! Many thanx!

    • @rajshekarreddy5358
      @rajshekarreddy5358 Год назад

      @@karytsi Hello keytsi, I tried installing the remotes package. I'm still getting the same error, Did it work for you?

    • @karytsi
      @karytsi Год назад

      @@rajshekarreddy5358 yes, it did, but that was 2 months ago... Maybe smthg changed

    • @rajshekarreddy5358
      @rajshekarreddy5358 Год назад

      @@karytsi Thanks for the reply. I'm struck at that error, tried all means. couldn't resolve it. If possible, please share your code and help me out in this regard.

  • @Etaupsiolon
    @Etaupsiolon Год назад

    Hi Spencer.
    Can you help me with this?
    Error in rayrender::render_scene(scene, lookfrom = lookfrom, lookat = camera_lookat, :
    Must specify a minimum width/height of 3 or more pixels

    • @MrPecners
      @MrPecners  Год назад

      Where in the code are you encountering this error?

    • @ahmedhannan4083
      @ahmedhannan4083 Год назад

      @@MrPecners I also faced same issue. I faced it here
      > render_highquality(
      + filename = "images/test.png",
      + interactive = FALSE,
      + lightaltitude = c(20, 80),
      + lightcolor = c(c1[2], "white"),
      + lightintensity = c(600, 100),
      + )

    • @Etaupsiolon
      @Etaupsiolon Год назад

      @@MrPecners > render_highquality(
      + filename = "images/test_plot.png",
      + interactive = FALSE,
      + lightaltitude = c(20, 80),
      + lightcolor = c(c1[2], "white"),
      + lightintensity = c(600, 100),
      + )

    • @MrPecners
      @MrPecners  Год назад

      I think you just need to add the width and height arguments, e.g.:
      render_highquality(
      filename = "images/test.png",
      interactive = FALSE,
      lightaltitude = c(20, 80),
      lightcolor = c(c1[2], "white"),
      lightintensity = c(600, 100),
      # specify width and height
      width = 800,
      height = 800)

  • @FleurDeCo.
    @FleurDeCo. Год назад

    Where is the 30 day map challenge located?

    • @MrPecners
      @MrPecners  Год назад +1

      It primarily takes place on Twitter. Every day has a different theme, and people tweet their submissions using the #30DayMapChallenge hashtag.
      Here's the website for the challenge: 30daymapchallenge.com/.

  • @mathewsjoy8464
    @mathewsjoy8464 Год назад

    Hey Nice video!, just stuck at 33 when I try to plot the data, it gives me a data error and makes me start a new session, cant seem to find any help online, anyone have any idea why this is?

    • @MrPecners
      @MrPecners  Год назад

      Hmm, I'm not sure offhand. What exactly is the error?

    • @Secretly2Robots
      @Secretly2Robots Год назад

      make sure you have installed the rgl package

  • @luccampbell
    @luccampbell Год назад

    Anyone have a good package to do this with Canadian maps?

    • @MrPecners
      @MrPecners  Год назад

      You can download the population data from Kontur for Canada, and then you just need the boundary polygons for whatever area you want to map. To get those, have you tried raster::getData(name = "GADM", country = "Canada")? There's a "level" argument that will return different administrative boundaries (e.g. country, province, etc.). Otherwise, I'm sure there's a state service that allows you to download shapefiles.

  • @kevinalexis9886
    @kevinalexis9886 Год назад

    Is anyone familiar with the following ERROR:
    Error in c.units(x = nx[[1L]], y = ny[[1L]]) :
    units are not convertible, and cannot be mixed; try setting units_options(allow_mixed = TRUE)?

    • @MrPecners
      @MrPecners  Год назад +1

      Wrapping w_ratio and h_ratio in as.numeric() should solve this.

    • @kevinalexis9886
      @kevinalexis9886 Год назад

      I tried using the both solutions mentioned before:
      units_options(allow_mixed = TRUE)
      and
      drop_units(w_ratio)
      Without any success Im now getting the following ERROR:
      Error in stopifnot(is.character(values), is.numeric(x)) :
      argument "values" is missing, with no default

  • @mtownsprts
    @mtownsprts Год назад

    I keep getting an error:
    Error in rayrender::obj_model(cache_filename, x = -bbox_center[1], y = -bbox_center[2], :
    unused argument (texture = TRUE)
    Not entirely sure what this means. I am attempting to run the portion of your code from your github that renders the higher quality file. (the last section of the code) But i keep getting this error when attempting to run render_highquality()???

    • @MrPecners
      @MrPecners  Год назад +1

      I haven't tracked down exactly why that error is thrown, but I've heard from others that installing the most recent dev version of the package solves it. Install with remotes::install_github("tylermorganwall/rayshader"). You might need to update the rayrender package as well (which rayshader uses behind the scenes), install that with remotes::install_github("tylermorganwall/rayrender"). You need the remotes package there, so you might have to download that as well: install.packages("remotes").

    • @miaocai2078
      @miaocai2078 Год назад +1

      Try updating the two packages as suggested by Spencer. It works for me.

    • @alessandroippoliti1523
      @alessandroippoliti1523 Год назад +1

      The current version of the rayrender and rayshader packages have an extra argument (i.e. texture = TRUE) when calling the function. You can remove it by typing 'trace(render_highquality, edit = TRUE)' and opening up the function, then scrolling to where the obj_model() function is called and removing the entry. There are also other issues with the functions however and the best way to solve them is to install them through Github and not the internal package installer program. Took me a whole day to figure this out, hope it helps you progress

    • @IrakliKavtaradzepsyche
      @IrakliKavtaradzepsyche Год назад

      @@alessandroippoliti1523 now the error says the function is corrupted. Can't get around this error

    • @kunalkunal6227
      @kunalkunal6227 Год назад

      I have got the same issue. I updated the dev version and rayshader but still has the same issue. Any thoughts?

  • @sagarrawal8332
    @sagarrawal8332 12 дней назад

    Did i miss something in tutorial ? How that 400 meter ( 1/4th mile) was calcualted ?

    • @MrPecners
      @MrPecners  12 дней назад +1

      It’s not calculated in the video, that’s provided by the data source, Kontur.

    • @sagarrawal8332
      @sagarrawal8332 12 дней назад

      @@MrPecners Thank you. The tutorial was indeed very helpful.

    • @sagarrawal8332
      @sagarrawal8332 11 дней назад

      @@MrPecners How to add scale to show the density value of minimum and maximum density ?

    • @sagarrawal8332
      @sagarrawal8332 10 дней назад

      @@MrPecners Is there a way to add color bar with range of matrix using same texture as in plot?

  • @jigmetenzin7596
    @jigmetenzin7596 Год назад

    Great tutorial. Could you share your code?

    • @MrPecners
      @MrPecners  Год назад

      github.com/Pecners/kontur_rayshader_tutorial

  • @vijayjadhav3120
    @vijayjadhav3120 Год назад

    What should I use instead of States for Indian States because whenever I right glimpses it shows me data of US states not Indian. Stuck there please help 😑

    • @MrPecners
      @MrPecners  Год назад

      Try using raster::getData(). More details in the comment here from Rajat Lohia.

    • @vijayjadhav3120
      @vijayjadhav3120 Год назад

      @@MrPecners Well, I tried using his method but it didn't work.

    • @nishanthhebbar4888
      @nishanthhebbar4888 Год назад

      @@vijayjadhav3120 the code by Rajat Lohia works for Indian states. I can confirm this.

    • @Trappenheimer
      @Trappenheimer Год назад

      @@nishanthhebbar4888 can you give me the link for the code of Rajat Lohia?

  • @burak57646
    @burak57646 Год назад +1

    Thank you for the tutorial 🖐. I have an error called "R session aborted" when I click ctrl + enter in this part;
    mat |>
    height_shade() |>
    plot_3d(heightmap = mat).
    A new window is coming and then I encountered this error. Do you know what can I do?

    • @ceciliagaland
      @ceciliagaland Год назад

      Same, could you send how to solve the issue if you had found ?

    • @Secretly2Robots
      @Secretly2Robots Год назад

      make sure you have the rgl package installed

    • @DataOperationsandResearch
      @DataOperationsandResearch Год назад

      Hello everyone. If you guys are working on Windows with R 4.2 and the Rstudio crashes/terminates when you run
      mat |>
      height_shade(texture = texture) |>
      plot_3d(heightmap = mat,
      zscale = 100
      )
      Then you should use solid = FALSE in the above function and Rstudio would not terminate. So, use the function
      mat |>
      height_shade(texture = texture) |>
      plot_3d(heightmap = mat,
      zscale = 100,
      solid = FALSE,
      )
      This problem could be specific to operating system and/or Rstudio/R version. But both I and my colleague faced this issue and it was a working fix.

    • @mayur_kumar
      @mayur_kumar Год назад

      Also would be a good idea to save the workspace, so that you don't have to run intersection each time.

  • @balighbenabdessalem2569
    @balighbenabdessalem2569 Год назад

    the code please

    • @MrPecners
      @MrPecners  Год назад +1

      github.com/Pecners/kontur_rayshader_tutorial

  • @ahmedhannan4083
    @ahmedhannan4083 Год назад

    Hello Spencer. Thanks a million for your tutorial! I wanted it for long. Can you please help me to get this working?
    > render_highquality(
    + filename = "images/test_13.png",
    + interactive = FALSE,
    + lightaltitude = c(20, 80),
    + lightcolor = c(c1[2], "white"),
    + lightintensity = c(600, 100),
    + )
    I get this ERROR
    Load failed: can't fopen
    Error in render_scene_rcpp(camera_info = camera_info, scene_info = scene_info) :
    Loading failed of: C:/Users/Dell/AppData/Local/Temp/RtmpiMqGxG\C:\Users\Dell\AppData\Local\Temp\RtmpiMqGxG\temprayfile.png-- nx/ny/channels :0/0/0

    • @MrPecners
      @MrPecners  Год назад

      Hmm I haven't seen that error before. Are you updated to the latest dev versions of rayshader and rayrender? Use the code below to install those versions, and be sure to restart your R session.
      remotes::install_github("tylermorganwall/rayshader")
      remotes::install_github("tylermorganwall/rayrender")