Hacker News new | past | comments | ask | show | jobs | submit login
Rayshader – An open-source R package for producing 2D and 3D hillshaded maps (rayshader.com)
150 points by mxfh 3 months ago | hide | past | web | favorite | 21 comments

Developer of rayshader here: If you're interested in some of the thought process and details that went into creating and developing the package, I have a series of blog posts detailing them here (in order of appearance):

http://tylermw.com/throwing-shade/ HN comments: https://news.ycombinator.com/item?id=17065264

http://www.tylermw.com/making-beautiful-maps/ HN comments: https://news.ycombinator.com/item?id=17424061

http://www.tylermw.com/3d-maps-with-rayshader/ HN comments: https://news.ycombinator.com/item?id=17697046

http://www.tylermw.com/3d-printing-rayshader/ HN comments: https://news.ycombinator.com/item?id=17851229

http://www.tylermw.com/portrait-mode-data/ HN comments: https://news.ycombinator.com/item?id=18282640


Fwiw, you can optimize your height map / grid traversal [1] quite a bit. There don’t need to be any ceil/floor calls within the inner loop if you do a “3D DDA” iteration (like Bresenham’s for lines but in 3D).

We used to have good slides on this from Steve Parker’s CS 6620 at Utah, but modern versions of the class seem to use OptiX instead. Some folks put their code up online, so if you search for CS 6620 and height map or terrain you might find it. Useful for volume rendering too!

[1] https://github.com/tylermorganwall/rayshader/blob/master/src...

Great idea! The mesh it iterates over is inherently 2D (the surface intersection test just performs a bilinear interpolation between the grid points to compare to the ray height) so Bresenham's algorithm would work here. I'll implement it and see if it offers any significant speed improvements.

Really nice work - thanks for sharing.

These beautiful 3D shaded relief maps have been going past in my social feeds recently - https://scottreinhard.com/Mapping-and-Visualization - seems like your tool could be used to make something similar without requiring familiarity with 3D modelling packages (Blender I think).

Yep, I've seen those, and I've been tempted to throw together an example with rayshader to show how easy it is to do with just a few lines of code.

One of the main motivations behind developing rayshader was to democratize mapping--forcing people to become proficient in not one but two highly specialized software suites (any GIS software + blender) really made beautiful mapping unattainable for most. Plus, I just dislike GUIs in general, and wanted a code-based solution for map making :)

I'd love to see how you do this with rayshader.

Love it - thank you.

Amazingly beautiful work. Thanks for sharing your knowledge and process!

It would be cool to combine this with some kind of classifier for surface types and simulate water, glass, reflections, sub-surface scattering (basically other types of materials).

Have you played with any of the new hardware raytracing API’s from Nvidia RTX stuff?

I have not, but I'm including gltf 2.0 support in an upcoming version, so it should be possible to start exporting visualizations created with rayshader to more traditional 3D graphics workflows where you could take advantage of those features.

What was the render time?

A second or two for everything you see here--the raytracing and color mapping bakes the texture into the surface, so after that the user can manipulate the 3D model to how they see fit. On larger datasets (10,000 x 10,000) it takes about a minute or so with default settings, but the user can cache the texture so they only have to calculate it once.

That's some beautiful looking work!

Excellent work ! Any examples with urban landscapes ?

Thanks! Halfway down the page on this [1] post I share an image made with lidar data of downtown Austin. Lidar data is fairly noisy (this required a bit of pre-processing to remove artifacts) but you can indeed capture an urban environment fairly well.

[1] https://www.tylermw.com/portrait-mode-data/

Where do you get the maps to make these?

The maps are generated directly from elevation data--all you need is an array of elevation values and the full maps are generated from those. A good source of elevation data for the USA is the National Map [1], but a much more comprehensive source is the SRTM Space Shuttle data [2] (it covers almost the entire earth at a 30m resolution).

[1] https://viewer.nationalmap.gov/basic/ [2] https://dwtkns.com/srtm30m/

Thanks! Follow up question: how do I zoom in once I have loaded in a GeoTIFF from one of those sources?

To zoom, just subset the matrix to the region of interest

Take a look at the AWS Elevation Tiles: https://registry.opendata.aws/terrain-tiles/

While at Mapzen (RIP), I helped generate these from a wide selection of open elevation data sources.

FYI Mapzen is coming back as a Linux foundation project (just announced in the last week):


beautiful :)

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact