Это видео недоступно.
Сожалеем об этом.
Rayshader Tutorial-Florida Population Density
HTML-код
- Опубликовано: 14 авг 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/Pec...
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/tyl...")
remotes::install_github("github.com/tyl...")
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)"
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.
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.
I solved the st_rasterize by including this in my code: library(units)
units_options(allow_mixed = TRUE)
@@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?
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").
@@MrPecnersThank you for the suggestion! I had the same error.
@@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!
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
Glad you got it to work!
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.
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!
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?
Was looking for something like this for soooooooo long
Thanks a lot🙏
You bet!
Hey nikhil, please help me, I'm unable to load the data into rstudio. I've downloaded the data from the website.
Amazing video thanks so much! One suggestion would be to demonstrate how to add labels to different cities
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
I'm getting the same error
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
@@MrPecners thank you so much ;)
Amazing work, thank you.
This is great thanks for sharing!
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?
What’s the difference between the matrix size and the high quality render size(width/height)?
You are amazing, great project!!!! And thank you to share your knowledge
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
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()
I love it ! Thank you so much
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
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)
Reading (data
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?
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.
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
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
🙏🏻
Esta genial, saludos desde Ecuador.
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?
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.
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.
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.
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
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?
I getting issue with rgl package, did anyone else experience this issue it says: rgl.viewpoint is deprecated!!
Hello Spencer, like Tigris package is specifically for US Shapefile. Can you help me with the package solely for Indian shapefile?
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
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
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?
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?
@@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 :)
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()
@@MrPecners Thank you so much! Legend!
Wow. Cool Stuff. Impressive. Thank you.
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")
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!
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
can we put some gpu acceleration on this? my cpu is dying
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...
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.
@@MrPecners OK! Got it! Many thanx!
@@karytsi Hello keytsi, I tried installing the remotes package. I'm still getting the same error, Did it work for you?
@@rajshekarreddy5358 yes, it did, but that was 2 months ago... Maybe smthg changed
@@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.
Thanks for the amazing guide 😊 Any idea why my matrix is appearing hollow when it hits the boundaries of the area?
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.
update: I solved this issue by XQuartz on macOS, thanks
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.
Hmm I'm not sure offhand. I think I saw you post something on Twitter though, did you figure this out?
Awesome content. How would you label/identify with text on the map the cities of florida? Thanks
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...
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!!!
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.
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?
Good question--I prefer having everything scripted out so that it's easier to reproduce, plus it keeps everything contained within R.
@@MrPecners I see
> florida_rast
Can you do a tutorial for a Country such as Italy for example?
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.
@@philippsidler2408 yeah doing a class project in Tripoli Libya and definetly hard to extract unlike the states
@@philippsidler2408download shapefiles for Switzerland and follow the same procedure. Use st_read to read shapefile.
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?
Been doing this and at only at 58:24 you just mentioned you are on Macbook Pro. hahaha
Hi! Great tutorial! Woult it possible to do a similar map but with elevation data? Thanks
Please help me, I'm unable to load the data after downloading into Rstudio.
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!!
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.
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!
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.
@@MrPecners Thank you very much for information!
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)?
Wrapping w_ratio and h_ratio in as.numeric() should solve this.
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
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.)
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.
@@MrPecners Thanks for the reply
Amazing tutorial, i am unable to install said packeges from GitHub, getting error while rendering High quality picture.
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.
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)
Same problem here. I updated rayrender and rayshader
Did i miss something in tutorial ? How that 400 meter ( 1/4th mile) was calcualted ?
It’s not calculated in the video, that’s provided by the data source, Kontur.
@@MrPecners Thank you. The tutorial was indeed very helpful.
@@MrPecners How to add scale to show the density value of minimum and maximum density ?
@@MrPecners Is there a way to add color bar with range of matrix using same texture as in plot?
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 😢
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?
Hi Spencer, is it possible to add the geographical boundary for Florida using sf polygons in the plot?
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.
@@MrPecners Great! Thanks for the suggestions! Looking forward to more video tutorials from you!
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.
Can you share the full code of your render_highquality() call?
@@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
@@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
@@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
@@MrPecners UPDATE: imgs render correctly titles but still no luck making the render as in the video
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
I mean after removing the solid layer
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.
@@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.
There's nothing that can't be solved by restarting R I guess. The problem's gone.
@@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?
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?
Hmm, I'm not sure offhand. What exactly is the error?
make sure you have installed the rgl package
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
Where in the code are you encountering this error?
@@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),
+ )
@@MrPecners > render_highquality(
+ filename = "images/test_plot.png",
+ interactive = FALSE,
+ lightaltitude = c(20, 80),
+ lightcolor = c(c1[2], "white"),
+ lightintensity = c(600, 100),
+ )
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)
Anyone have a good package to do this with Canadian maps?
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.
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?
Same, could you send how to solve the issue if you had found ?
make sure you have the rgl package installed
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.
Also would be a good idea to save the workspace, so that you don't have to run intersection each time.
Where is the 30 day map challenge located?
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/.
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()???
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").
Try updating the two packages as suggested by Spencer. It works for me.
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
@@alessandroippoliti1523 now the error says the function is corrupted. Can't get around this error
I have got the same issue. I updated the dev version and rayshader but still has the same issue. Any thoughts?
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 😑
Try using raster::getData(). More details in the comment here from Rajat Lohia.
@@MrPecners Well, I tried using his method but it didn't work.
@@vijayjadhav3120 the code by Rajat Lohia works for Indian states. I can confirm this.
@@nishanthhebbar4888 can you give me the link for the code of Rajat Lohia?
Great tutorial. Could you share your code?
github.com/Pecners/kontur_rayshader_tutorial
the code please
github.com/Pecners/kontur_rayshader_tutorial
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
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")