Background:
I am writing a script to analyze Minecraft worlds for biome diversity. For a given seed (say, 535310562
), I can obtain a map of the world as an HTML Canvas from https://www.chunkbase.com/apps/biome-finder#535310562. I would like to download the canvas using R, and then count the number of unique colors (each color represents a different biome) to determine the number of biomes present.
Problem: I don't know how to analyze pixels in an HTML Canvas using R.
Possible solutions: I've thought of two ways of solving this problem. First, If there's a way to iterate through the pixels in an HTML Canvas using R, the problem becomes trivial. Second, I could first download the image as a gif/bmp/png and read the pixel values from the downloaded image.
Progress so far: I know how to index the canvas node using rvest, but I don't know where to go from here.
if (!require("rvest")) install.packages("rvest")
randomSeed <- floor(runif(1,-2147483648,2147483647))
urlBase <- paste("https://www.chunkbase.com/apps/biome-finder#",randomSeed,sep="")
biome_wbpg <- read_html(urlBase)
canvas <- html_node(biome_wbpg,"canvas")