[R-sig-Geo] Drawing the maximum-area rectangle in a non-convex polygon
b.rowlingson at lancaster.ac.uk
Wed Apr 13 13:51:09 CEST 2016
On Tue, Apr 12, 2016 at 10:48 PM, Tiernan Martin
<tiernanmartin at gmail.com> wrote:
> Hi Barry –
> http://d3plus.org/assets/posts/largestRect/src/largestRect.coffee ?
> give it a shot for this project. However, since this would be my first time
> trying to run JS code in R (and given that the algorithm itself isn't
> exactly a simple one) I thought I would start by querying the R user
> community to see if there's already an R implementation of something
> similar. It had also occurred to me that I could attempt to reimplement the
> JS code using R functions, but that project quickly took me beyond my R
> skill set.
Check out the V8 and js packages. That script you linked to is
actually CoffeeScript, but that's a thin shell around Javscript and
"transpiling" to JS is covered in the vignettes of the V8 and js
packages somewhere. Then all you need to do (hah!) is load the d3
Simple... ummm... maybe.
> It certainly seems to be the sort of spatial analysis problem that could be
> applicable to lots of different projects, so I'm hoping to get some
> feedback from folks with deeper understanding of programming and R – or
> simply to have someone point out a nicely packaged set of functions that
> could do this analysis.
I've had a quick look at the CoffeeScript and while it could be
converted to R there's a lot of looping and I suspect it might be
painfully slow unless you spend lots of time to consider the algorithm
so you can write it in properly idiomatic R. It might even benefit you
to rewrite it in C or C++....
More information about the R-sig-Geo