在Rcpp函数中使用geos [复制](Using geos inside a Rcpp function [duplicate])

编程入门 行业动态 更新时间:2024-10-23 23:25:14
在Rcpp函数中使用geos [复制](Using geos inside a Rcpp function [duplicate])

这个问题在这里已经有了答案:

使用Rcpp 1答案 从C ++调用用户定义的R函数

任何人都有如何在Rcpp函数中使用geos的提示(我正在构建一个R包)? 其实,我正在寻找一个更好的方法,那么这个:

Rcpp::Environment rgeos_env = Environment::namespace_env("rgeos"); Rcpp::Function Dist = rgeos_env["gDistance"];

情境化,我想计算空间多边形之间的距离,但我做了很多次( 蒙特卡洛测试 ),我想提高我的代码速度。

This question already has an answer here:

calling a user-defined R function from C++ using Rcpp 1 answer

Anyone have a hint in how to use geos inside Rcpp functions (I'm building an R package)? Actually, I'm looking for a better approach then this:

Rcpp::Environment rgeos_env = Environment::namespace_env("rgeos"); Rcpp::Function Dist = rgeos_env["gDistance"];

Contextualizing, I want to calculate distances between spatial polygons, but I do that a lot of times (Monte Carlo Tests) and I want to improve the speed of my code.

最满意答案

我看到两种可能的方法来使用geos,而不用从C ++返回到R:

尝试链接到rgeos包, 使用Rcpp中其他包的C函数

做rgeos软件包的工作,即链接geos库并调用相关函数,参见https://github.com/cran/rgeos/blob/28403d4d4adbc3bd76c11e4c55dec7e097d74f6d/src/rgeos_misc.c#L50

I see two possible approaches to use geos without going back to R from C++:

Try to link with the rgeos package, c.f. using C function from other package in Rcpp

Do what the rgeos package does, i.e. link with the geos library and call the relevant functions, c.f. https://github.com/cran/rgeos/blob/28403d4d4adbc3bd76c11e4c55dec7e097d74f6d/src/rgeos_misc.c#L50

更多推荐

本文发布于:2023-07-22 12:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219940.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   Rcpp   geos   duplicate   function

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!