knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
Manifoldr allows direct connection to Manifold .map projects from R via ODBC. We can read tables in full, or issue SQL queries to select or dynamically create new tables.
library(manifoldr) mapfile <- system.file("extdata", "AreaDrawing.map", package = "manifoldr") (x <- Drawing(mapfile))
Note the mixed types which are now available in R via sf
Basic Manifold queries work, using the "WHERE" argument.
Drawing(mapfile, WHERE = "WHERE [Type (I)] = 2") Drawing(mapfile, WHERE = "WHERE IsLine(ID) AND [Length (I)] < 2500")
Exciting!
1) manifoldr
relies on ManifoldĀ® System GIS, it's of no use if you don't have this installed and working.
2) manifoldr
is only available from GitHub: the easiest way to install it is to use the devtools
package.
if (packageVersion("devtools") < 1.6) { install.packages("devtools") } devtools::install_github("mdsumner/manifoldr")
(Future versions may become available on CRAN. )
The ODBC driver for Manifold is read-only, so we cannot modify the contents of an existing file.
Please take care not to modify a Manifold project while an R session has a open connection to it. If you try to save such a project, you will get an error seen below. If you see this, and you want to save your changes you must choose "Yes", and save the file to a new location. There is no other option that I know of:
Drawings that use a Local Scale different from 1.0 and/or a Local Offset different from 0.0 will not be read with correct geometry. I'm not sure how to work through this yet.
There are many issues with the conversion from Manifold to WKT or PROJ.4 strings, there's a lot of work to do here.
All the standard Manifold SQL is available.
NOTE: this will be merged with mdsumnner/dplrodbc in some way. Was originally called RforManifold.
Manifold GIS and R make for a powerful partnership, but the coupling between them has been relatively loose and sketchy.
Two key recent R packages make the coupling more compelling:
The main ways we connect R and Manifold are
1) read drawing layers with data from Manifold .map files via SQL queries 2) drive the Manifold API directly via .Net. 3) (developing) simplify the queries via dplyr
The first provides a pretty tight mapping of high-level data types, i.e. in Manifold we have a drawing and in R we have a Spatial layer and moving from one to the other is easy.
The second provides a lot more power but we need to do more work to transfer data between the systems.
There are lots of other pathways, including GDAL as a third/fourth party and via file transfer.
See the package vignettes for examples.
ODBC_binary
type from the RODBC
package. Be careful with these columns as they do not have compact printing methods. This is something to added to a future version of this package. https://github.com/mdsumner/talks/blob/master/SQL_3/SQL_3.rmd
dig up the RODBC reader https://github.com/mdsumner/mdsutils/blob/master/R/odbcReadManifold.R
get rClr working with Manifold: install from here https://github.com/jmp75/rClr
parallel CGAL triangulation code with Manifold's DecomposeToTrianglesAdv
https://github.com/mdsumner/dplyrodbc
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.