Giter VIP home page Giter VIP logo

anglr's Introduction

hypertidy

[ ... ]

The hypertidy work plan

Build out a core set of packages for developing projects.

core components

  • point-in-polygon (see pfft, spacebucket, polyclip)
  • path-reconstruction-from-edges (dodgr magic)
  • distance-to and distance-from (best currently is spatstat and sf)
  • discretization and other forms of coordinate transformation
  • core input interfaces that are lazy, see lazyraster/vapour and tidync as workings toward a common framework

vapour

  • check vapour on MacOS
  • check license / copyright issues for vapour
  • build sfcore
  • put core raster logic in discrete

NetCDF

  • fix group_by for tidync
  • find a way to cut dimensions (dplyr::tile?)

anglr

  • integrate TR's quadmesh helpers

silicate

  • dynamic edges, record original start/end edge with throw-away Steiner points?

  • inner cascade and semi cascade, names for the concept, activate to start in the middle, formal join-ramp

  • finish edge and arc-node workers

  • restructure sc around the gibble concept

  • consolidate silicate (remove sc/scsf)

  • release unjoin and gibble for use by the sc family

overall approach

The hypertidy approach to complex data structures aims to bring the goals of the tidyverse to spatial data with this single point of perspective: the only thing that makes geo-spatial data special is the system of coordinate transformations that provide a family of compromises for generating and working with a particular set of space-properties. All the other aspects that get special attention are completely shared by other domains such as graphics, model structures, grid domains and aspects of user-interactivity and ease of use. Further, the tidy principles dictate that the majority of data manipulation and analysis is best handled using database principles and technologies, and "geo-spatial" is no different. No special handling is required, and we believe strongly, current idioms and established practices involving special handling hinder innovation, education and understanding generally. Other fields have essentially solved all of the main problems in data analysis, handling and user-interaction but traditions in other fields are preventing the use of these solutions in optimal ways.

This applies to drawings, GIS vector points, lines, areas, simple features, segment-based linear paths, triangulations and other forms of meshes, and we consider them all to be one of a piecewise linear complex or a simplicial complex, with (this bit is crucial) further levels of organization within and between primitive components.

Recent legacy optimizations made in geo-spatial fields have seen a strong focus on the path, which is an ordered sequence of coordinates, and the path is implicit, defined by "joining the dots" between each coordinate. There is a dual to the path, which is an unordered set of edges (a.k.a. line segments) where each pair of coordinates traversed by an edge is reference implicitly by name.

This provides a set of forms for complex structures that collectively allows generic transformation workflows.

    1. Bespoke formats. This is what we have, there are many.
    1. Structural vertex-instance set and path-geometry map.
    1. Normal form path topology.
    1. simplicial complex forms

The last two here include vertex-topology, in that each vertex is a unique coordinate and may be referenced multiple times. 1 is a special case for transition between path based forms

There are several required forms. It's not clear to me that the below is a sequence, for example arc-node is not necessarily a good pathway from 3 to 5, since 4 is an specialization of planar linear forms for polygons or networks, not an required intermediate.

1 and 2 suffer from requiring an implicit or structural order for the sequence of coordinates within a path.

  1. Paths in multiple tables with a form of structure index, a run-length map. This is what sc_coord, sc_path, and sc_object provide.
  2. Relational paths, no structural index and no de-duplication, all that is needed is vertex, path, object.
  3. Relational paths normalized by vertex, requires a path_link_vertex table to link the path and de-duplicated vertices.
  4. Relational paths normalized by vertex and by path. It's probably never worth normalizing a polgonal path, but it is worth it for arc-node models, such as TopoJSON, OSM ways, and the data at the core of the maps package.
  5. Relational directed linear segments, first form treats segments in the way that 2 treat coordinates - no de-duplication, and so the path is record with the segment ID.
  6. Relational undirected linear segments, this second form de-duplicates segments, ignoring their orientation, and requires a new link table between segment and path (that is where the orientatoin could be stored, if it's needed). (This is what TopoJSON does, storing a 1 or -1 for orientation.
  7. Relational triangles, composed of segments.
  8. Relational triangles, forget the segments.
  9. Higher forms?

path

  • same for polygons and lines and points
  • involves normalization of vertices, but maybe it should not
  • object, path, coordinate
  • combining paths is trivial, possibly is the lowest common denom for merging

path_topological

  • could involve vertex normalization
  • arc normalization?
  • how to record/infer closed paths, probably is explicit?
  • object, path, coordinate, vertex
  • combining these is tough, need first to -- expand all coords? -- normalize vertices of separete inputs, then merge?

: arc normalization is problematic I think, does it imply segment normalizatoin first?

: is part of the key here to keep links to the inputs as they were?

segment / 1D primitive

  • true edge graph
  • definitely requires node inference and inclusion

triangles / 2D primitive

  • segment is truly a prerequisite
  • CGAL seems prone to duplicates and cross over segs

Inputs?

  • lines and lines, needs noding result is

Lessons from silicore

https://github.com/hypertidy/silicore#the-longer-silicore-story

Lessons from the space bucket

Point in polygon is core.

Determining if a point falls inside a ring is classifying that point with that path. When paths can be nested there needs to be logic for holes, and for multiple classifications - however it's achieved. Obviously the search space can be optimized for multi-points, multi-paths.

In hypertidy/pfft we isolate the conversion of an edge-form to a triangulation and its complementary point-in-path so we can filter out holes and classify triangle instances.

Paths or segments?

We absolutely need both, for intersections we need the triangle filtering/classification. The gibble is a run-length-encoding into the in-order set of coordinate instances, and this is straightforward from native-sf, and also straightforward from the dense vertex set as long as the order can be maintained - otherwise via path-composition from arbitrary edges. I feel that the gibble is invalidated by vertex densification, and probably we don't care if path-composition is trivial, and holes are inherent in triangulations anyway. At any rate, if we use a triangulation for intersection, then it is the dead-end, because it provides information about the SF inputs. Otherwise we leave the inputs behind and use only primitives, then restore as needed.

Extents is core

We need entities that act like a set of bbox/extents - storing only four numbers for each. An SF-form from these is purely on-demand. A raster is the densest, a rectlinear grid is next, and corner-based mesh is next, then the set of quads as a special case of the more general "set of extents".

We use an extents entity to quad-tree optimize things like point-in-polygon classification.

anglr's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

anglr's Issues

polygon/line structural sameness

from Miles:

In "What makes polygons different to lines?" None of your arguments for segments made much sense > to me, since they contained a lot of domain knowledge. I think that's fine given the package audience, > but you might consider rewording a little for accessibility.

hawaii example

devtools::install_github("r-gris/rangl", ref = "devel")


library(rangl)
library(raster)
library(marmap) ## has topo data
data(hawaii)
library(rgeos)
haw <- setExtent(raster(unclass(hawaii)), extent(unlist(lapply(attr(hawaii, "dimnames"), function(x) as.numeric(c(head(x, 1), tail(x, 1)))))))
projection(haw) <- "+proj=longlat +ellps=WGS84"

hpoly <- rasterToPolygons(cut(haw, c(cellStats(haw, min), 0, cellStats(haw, max))), dissolve = TRUE)

## just some polygons
hpoly <- rgeos::gPolygonize(rasterToContour(cut(haw, c(cellStats(haw, min), 0, cellStats(haw, max))), lev = 1.5))

rework anglr do-all function

Probably remove this function, or at least split existing functionality into

  • primitives_triangle, primitives_segment, primitives_point
    or
  • primitives2d, primitives1d, primitives0d

See impetus here: #46

Ultimately we need to be able to have a model that has all of these things, which is what anglr might ultimately be able to do, a hyper-mapview. rgl has these mixed forms to a small degree, and we'd want to have lines and polygons in a model, sharing the same vertex pool - i.e. lines that follow terrain, and surfaces from contours. Can we sensibly have an everything-model that one function can build from any input, but also the family of functions that can add smaller parts to a larger model probably includes the functions above.

rgl conversion

first stab at mesh3d:

library(rgl)

x <- tetrahedron3d()
class(x)
str(x)
library(tibble)
fun <- function(x) {
  v <- setNames(as_tibble(t(x$vb[1:3, ])), c("x_", "y_", "z_"))
  v$vertex_ <- spbabel:::id_n(nrow(v))
  tXv <- tibble(vertex_ = v$vertex_[x$it], 
                triangle_ = spbabel:::id_n(ncol(x$it))[rep(seq(ncol(x$it)), each = 3)])
  tt <- tibble(triangle_ = tXv$triangle_[seq(ncol(x$it))], object_ = "1")
  o <- tibble(object_ = "1")
  structure(list(o = o, t = tt, tXv = tXv, v = v), class = "trimesh")
}

(Doesn't work)

bug: globe() doesn't modify the meta$proj record

It should at least replace the source projection with the geocent string used.

And . . . the meta table could record every transformation made, and maybe keep track of what the current default attributes are . . . and their units . . .

globe is broken

a <- countriesHigh[9, ]
 b <- tri_mesh(a)
 plot(b)
 globe(b)
 Error in x$vb[1, x$it] : no 'dimnames' attribute for array 

flight_tracks example

@kent37 thanks for the data, I've included it within the package silicate, which I hope is ok? There it is in PATH form, which you can create from an sf with silicate::PATH( ). There's still another step into anglr form while I figure out the best way forward.

If you are feeling brave, try installing anglr, there is one other Github package silicate, and rgl and a few other packages are required from CRAN. You'll likely need a pretty recent version of R, I'm using 3.4.1.

The rgl.clear() at the start of the plot and rglwidget() is a bit of overkill, but it's necessary for me working on RStudio Server.

This project is still very early and raw, but it's looking promising. Let me know how it goes, good or bad - it's helpful to know any feedback. We can put other features in the scene easily enough, including polygons with topography relief and so forth, but all of that takes a bit of knowledge of the structures at the moment.

## devtools::install_github("hypertidy/silicate")
## devtools::install_github("hypertidy/anglr")

library(anglr)
library(rgl)
data("flight_tracks", package = "silicate")
## convert to topological graph
aa <- anglr(flight_tracks)

rgl.clear()
## sets up a basic plot, with a colour for each feature
##  (M is ignored, but it's in the model - see aa$v)
plot(aa)
## this is a hack, z-metres in lon-lat
## play with the third value by orders of magnitude
## but re-run the rgl.clear to rglwidget funs 
## completely start again if needed
aspect3d(1, 1, 0.0001)
## this call is not needed unless you are on RSTudio Server, or have no OpenGL rgl device
rglwidget()

Finally, a specific thing if you can let me know, are you able to rotate the scene as well as zoom in and out? I'm having troubles, I don't understand the details of rglwidget yet. :)

raster/quad slow in rglwidget

ah, no it's not building that is slow - quads are slow in rglwidget, why is that? Also noted back here:

http://mdsumner.github.io/2016/01/20/ManifoldRaster.html

There seems to be a limit in the size that can be handled

library(marmap)
library(raster)
library(rangl)
data("hawaii", package = "marmap")
r <- as.raster(hawaii)
p <- rangl(aggregate(r, fact = 8))
xy <- rgdal::project(as.matrix(p$v[, 1:2]), "+proj=laea +lon_0=180 +lat_0=-0")
p$v$y_ <- xy[,2]
p$v$x_ <- xy[,1]
plot(p)

There's also some issue with caching in RSTudio I think, the widgets are piling up maybe ... it's important to reproject the vertices above to remove any uncertainty about the aspect ratio in the plot.

lines are borked

library(spbabel)
sph <- sp(holey)
spl <- as(sph, "SpatialLinesDataFrame")
library(rangl)
plot(rangl(spl))

image

figure out licensing

is this just a wave for CRAN, or do we need to add more information to the pkg?

NOTE
Package has a FOSS license but eventually depends on the following
package which restricts use:
  RTriangle

It's unlikely that anyone is going to replace RTriangle::triangulate.

Could use manifoldr for those systems.

efficiencies for paths

Having many many lines is less efficient than it could be. But plotting segments is fast since you only need one plot call.

Is it also much faster in base lines() the same as in rgl? What about ggplot2?

  • remove object-loop for creating primitives in rangl.SpatialLines
  • always create primitives for lines and polygons, consider removing the branch model completely
  • develop examples based on particles, time series, tracks

Examples

See AMPS particle trajectories . . .

See geolife example

Dated contours from time series rasters

library(raadtools)
icefile_db <- subset(icefiles(), 
                     date > as.POSIXct("2015-12-15") & date < as.POSIXct("2016-03-01"))
dummy <- readice()
pex <- extent(60, 100, -70, -55)
xyl <- projectExtent(raster(pex, crs = "+proj=longlat +ellps=WGS84"), projection(dummy))

icestack <- readice(icefile_db$date, hemisphere = "south", setNA = FALSE, 
                    xylim = xyl)
library(dplyr)
library(spbabel)
l <- vector('list', nlayers(icestack))
for (i in seq(nlayers(icestack))) {
  cl <- spbabel::sptable(spTransform(rasterToContour(icestack[[i]], lev = 15), CRS(projection(xyl))))
  cl <- cl %>% filter(branch_ == 1, object_ == 1) %>% mutate(object_ = as.character(i)) 
 l[[i]] <- cl

}

ice <-  spbabel::sp(bind_rows(l), tibble(date = icefile_db$date), crs = projection(icestack))

Check out geozoo

Geozoo has a bunch of interesting geometries, but not many have edges. You can use ball pivoting from vcg to some extent.

Good grist for rangl.

How to plot a linemesh?

I downloaded a shapefile which sf read in as a MULTILINESTRING. anglr converts this to a linemesh, which I don't understand how to draw in 3D. What am I missing?

Edit: I've committed the shape file and related code in alexander_clark_park in our vr_vs_sp repo.

lines, and refactor

include ability to "copy down" object attributes to vertices, for e.g. contour lines

need to think about how maintaining polygon branches sits with decomposing lines generally (probably always do it?)

relations


title: "Structures for hierarchical data in R"
author: "Michael Sumner"
date: "14 December 2016"
output: html_document

knitr::opts_chunk$set(echo = TRUE)

Hierarchical data is generally hard to deal with since the layout doesn't often match the way tools must then work with the data. Physical structures are used to match the logical structure in data sets, and this is not necessarily an efficient or flexible way to deal with the data itself.

** Example of extracting stuff from a nested list**

library(repurrrsive)
got_chars

Tables

The tidy framework in R generally dictates that the long form of tabular storage is the best way to work with statistical models and graphics.

The tools for converting from untidy nested structures, to long-form tables is well established, but the capacity to deal with
multiple related tables is more difficult.

What does nesting represent? Nesting in a tree-like structure represents data as nodes in a graph, with the parent-node and child-nodes as a straightforward encoding of relations.

Tree example of a nested list

These relations can be encoded in "normal-form", where the proper entities in the data structure are stored each
in a table, and the tree is not stored explicitly but as 1-many and many-1 links in relations.

** Table example of a nested list **


When the nodes in the graph are themselves tidy, it's very easy to convert from the nested recursive structure to a set of tables.

** Bag of relations **

A list of tables doesn't seem especially helpful, and it's not - at the user-level - but for a developer it's a very straightforward data structure to work with.

Tools to build a map of nested structure

Applying the map to extract tidy tables

Collapsing to entity tables

library(repurrrsive)

library(purrr)
library(tibble)
library(dplyr)
library(tidyr)
map_df(wesanderson, function(x) tibble(color = x), .id = "palette")

map(got_chars[[1]], length)


library(sf)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
map(st_geometry(nc), length)

nc %>% select(CNTY_ID, AREA, geometry) %>% mutate(len = at_depth(geometry, 1, length)) %>% filter(len > 1)

shp <- as(nc, "Spatial")
library(spbabel)
library(sp)
map_table(nc)

## break down nc and rebuild as tibble
tnc <- nc %>% select(-geometry) %>% as_tibble()
tnc$geometry <- st_geometry(nc)
st_as_sf(tnc) %>% by_row(map_table)
map_table.tbl_df <- function(x, ...) {
  map_table(st_as_sf(x))
}

x <- st_as_sf(tnc) %>% by_row(map_table) %>% select(.out)

Examples with spatial data

** Normal form for simple features **

** Primitives form (topology) **

** Recording aesthetics as variables with primitives **

** Recording variables generally on entities **

** Primitives from ggvis **

Autoplot for time

Try example with trip or similar, an auto rgl animation akin to the flying light ball example.

Is it worth piggy-backing on tourr at all?

triangle problem

This doesn't work, a certain combination of polygons and max_area - the linking with vindex$row_n is getting out of whack somehow, is it the order of the verts or is there somehow a too-small triangle throwing it out?

## problem
p <- sp::spTransform(wrld_simpl, "+proj=laea +ellps=WGS84")

edge <- rangl(p[seq(2, nrow(p), by= 8), ], max_area = 5e8)
plot(edges$v$x_, edges$v$y_, type = "n")
## the rangl tables are ... not fine
## because this plot is ... not fine
lapply(split(edge$tXv, edge$tXv$triangle_), function(x) lines((inner_join(x, edge$v) )[, c("x_", "y_")], col = "firebrick"))
#Joining, by = "vertex_"
#Error: not compatible with requested type 

## the rgl constructs are now bogus
## (the plot is true, the indexes are out of whack some how)
a <- plot(edge)
g <- plot(globe(edge))
ncol(a$vb)
ncol(a$it)

build notes - needed?

Build notes

  • Travis needs libproj-dev installed, via .travis.yml (CRAN does not)
  • R-hub needs SystemRequirements: PROJ.4
  • All need export RGL_USE_NULL=TRUE
  • plot in examples is fine, but there's a warning from R CMD check in interactive mode (??)

support BGM

BGM needs

  • mixed quads and triangles (use extrude3d though later use RTriangle)
  • bgm data structure probably should be rangl from the start

stack imbalance issue

I've seen this somewhere else too

cl <- contourLines(volcano)
d <- dplyr::bind_rows(lapply(cl, as_tibble))
library(dplyr)
library(spbabel)
x <- sp(transmute(d, x_ = x, y_ = y, branch_ = level, object_ = 1, order_ = seq(nrow(d))))
Warning: stack imbalance in '.Call', 168 then 167
Warning: stack imbalance in '<-', 166 then 165
Warning: stack imbalance in '{', 163 then 162
Warning: stack imbalance in '.Call', 167 then 166
Warning: stack imbalance in '<-', 165 then 164
Warning: stack imbalance in '{', 162 then 161
Warning: stack imbalance in '.Call', 166 then 165
Warning: stack imbalance in '<-', 164 then 163
Warning: stack imbalance in '{', 161 then 160
Warning: stack imbalance in '.Call', 165 then 164
Warning: stack imbalance in '<-', 163 then 162
Warning: stack imbalance in '{', 160 then 159

ssmu data set

This is a simple d admin map with 2 very detailed polygons with upwards of 100K and 200K vertices each, due to a baked-in coastline. The 14th polygon is fine, and comes out of rangl fine - the 17th takes a lot of memory (more than 20Gb) at last check to run the constrained Delaunay algo (without a max area value). This is not a reasonable test

triangles from quads

Something like this, index is not right yet.

Also, quad_mesh is using a structural index, which is baad.

quadToTriangle <- function(x) {
  v <- x$v
  v$vertex_ <- seq(nrow(v))
  meta <- x$meta
  tab <- x$qXv
  n4 <- nrow(tab) / 4L
  tXv <- tibble(vertex_ = rep(c(1, 2, 3, 2, 3, 4), n4) + rep(seq(0, length = n4, by = 3), each = 6))
  tXv$triangle_ <- rep(seq(nrow(tXv)/3), each = 3)
  x <- list(o = tibble(object_ = "1"), t = tibble(triangle_ = seq(nrow(tXv)/3), object_ = "1"), 
       tXv = tXv, v = v, meta = meta)
  class(x) <- "trimesh"
  x
}

winding overlay issue

Why doesn't $t[7, ] get filtered out by over?

library(sf)
library(dplyr)
library(rangl)
vpal <- function(n) {
  if (!is.null(dim(n))) {
    n <- nrow(n)
  }
  viridis::viridis(n)
}
p_self <- st_sfc(st_polygon(list(cbind(c(0, 0, 1, -0.1, -0.1, 1.5, 0), c(0, 1, 1, 0.2, 1.2, 1.2, 0)))))
ri <- rangl(as(p_self, "Spatial"))

p <- do.call(cbind, structure(list(x = c(-0.205701357466063, -0.0357229982293921, 
                                         -0.0697186700767263, 0.312732638205784, 0.4855439700964, 0.343895337399174, 
                                         0.471379106826677, 1.62156600432815), y = c(0.424072398190045, 
                                                                                     0.160605941373205, 0.336250245917765, 1.09831988982884, 0.54022427700177, 
                                                                                     0.732866417469998, -0.0801967342120795, 1.71024198308086)), .Names = c("x", 
                                                                                                                                                            "y")))
library(sp)
inp <- over(SpatialPoints(p), as(p_self, "Spatial"))
ploti <- function(x, col = NULL) {
  xx <- x %>% inner_join(pi$tXv) %>% inner_join(pi$v) %>% select(x_, y_) 
  #print(xx)
  polypath(xx, col = col)
  #$print(apply(as.matrix(xx), 2, mean))
  text(matrix(apply(as.matrix(xx), 2, mean), ncol = 2), lab = i)
}
plot(p)
plot(p_self, add = TRUE)
text(p, lab = sprintf("pt%i", seq_len(nrow(p))))
for (i in seq_len(nrow(pi$t))) ploti(pi$t[i, ], col =  scales::alpha("red", i/10))
data.frame(pt = seq_len(nrow(p)), pip = over(SpatialPoints(p), as(p_self, "Spatial")))

    pt pip
1  1  NA
2  2  NA
3  3   1
4  4   1
5  5   1
6  6  NA
7  7  NA
8  8  NA    

image

fusion

break and re-mesh by combining two together

plotting aesthetics for vertex vs primitive vs object

We need to differentiate

  • continuous: the vertex "v" table
  • discrete: the primitives or the object "o" table

Examples are the colour of a country in countriesHigh (discrete) vs. the colour scale across triangles (continuous).

Are there lessons from ggplot2 or scales for this?

Could we have "fill_cts" and "fill_dsc" args, mutually exclusive?

copy down

Copy down attributes from objects

  • to vertices, they are unique
  • to branches/primitives, potentially splitting what were shared (x.y) vertices

This allows columnar polygons or ribbon lines

compact indexes

this might be spbabel, but the indexes are extremely heavy - and this is really useful but - perhaps they just get created when merging or subsetting operations are happening, and we always resort to a counting index (though why have it at all ...)

support rlas/lidR

We need

  • RTriangle triangulate for sf types, especially MULTIPOINTZ
  • questions regarding triangulation within features, so this is more like the model of not-sharing vertices to connect multi-point geoms (it fits rangl but hasn't really come up before)
  • etc.

here's a raw example

library(lidR)
library(sf)
LASfile <- system.file("extdata", "Topography.laz", package="lidR")
lidar <- readLAS(LASfile)
ground <- lasfilterground(lidar)
library(dplyr)
pts <- local({
points <- st_sfc(st_multipoint(as.matrix(ground@data[, c("X", "Y", "Z")])))
d <- data.frame(file = "Topography.laz", method = "filterground")
d[["geometry"]] <- points
st_as_sf(d)
})
#sp_tri <- st_triangulate(pts)

rg_triangulate <- function(x, ...) UseMethod("rg_triangulate")

rg_triangulate.MULTIPOINT <- function(x, ...) {
    m <- as.matrix(x)
    x <- RTriangle::triangulate(RTriangle::pslg(P = m[, 1:2, drop = FALSE], PA = m[,3,drop = FALSE]), ...)
    a <- rgl::tetrahedron3d()
    a$vb <- t(cbind(x$P, x$PA[, 1, drop = FALSE], 1))
    a$it <- t(x$T)
    a
}

shade3d(rg_triangulate(pts$geometry[[1]], a = 5), col = "white")
points3d(as.matrix(lidar@data[, c("X", "Y", "Z")]))

generic TODO / explore list

Hawaii example

library(rangl)
library(raster)
library(marmap) ## has topo data
data(hawaii)
library(rgeos)
haw <- setExtent(raster(unclass(hawaii)), extent(unlist(lapply(attr(hawaii, "dimnames"), function(x) as.numeric(c(head(x, 1), tail(x, 1)))))))
projection(haw) <- "+proj=longlat +ellps=WGS84"

hpoly <- rasterToPolygons(cut(haw, c(cellStats(haw, min), 0, cellStats(haw, max))), dissolve = TRUE)

## just some polygons
hpoly <- rgeos::gPolygonize(rasterToContour(cut(haw, c(cellStats(haw, min), 0, cellStats(haw, max))), lev = 1.5))

plot(globe(rangl(haw * 280)))
rh <- rangl(hpoly)
rh$v$z_ <- 4e6
plot(globe(rh))

cell corners

need functions for raster vertexIndex_FromCell, or

ll_FromCell(raster, cells) 
lr_FromCell/tl_FromCell/tr_FromCell

where the four indices are implicit on the transform, and sparsely generated only for populated cells. Then generalize for L3bin, to tie together tabularaster and quadmesh.

Does this work by

  • translating centre cell index to ll/lr/tl/tr index
  • then just doing mod and %/% x, y to get the values

So the full set of coords is never generated, maybe never generated until transformed or visualized by rgl?

selection idioms

It would be neat to have "selected" behaviour, say to switch discrete / continuous aesthetics as per #3

A brushing mode could switch between these.

de-normalization of DEL vertices for Z

Everything is filtered out as being a hole, why? What about sc?

library(sf)
f <- "maps.nyc.gov/download/3dmodel/DA_WISE_Multipatch/DA_WISE_Multipatch/DA10_3D_Buildings_Multipatch.gdb"
d <- read_sf(f)

r <- rangl(d[1:10, ])

rename mesh

Sigh

sos::ff <- findFn("mesh")
AT.FLUKA.read.USRBIN.mesh
closemeshKD
distmesh2d
distmeshnd
mesh
mesh.2D.rectangular
mesh.2D.simple
mesh.dcircle
mesh.diff
mesh.drectangle
mesh.dsphere
mesh.hunif
mesh2grey
mesh2ply
mesh3d
meshcube
meshDist
meshgrid
meshintegrity
meshPlaneIntersect
meshres
mvmesh-geom
mvmesh-methods
mvmesh-package
mvmeshmisc
ply2mesh
quad2trimesh
quadmesh
ray2mesh
rmvmesh
rotmesh.onto
scalemesh
submesh.grid
submesh.mesh
tetramesh
theme_mesh
tri.mesh
trimesh
vcgUniformRemesh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.