Skip to content

Commit

Permalink
* Getting rid of dplyr and sp: replacing with collapse, sf and s2 + s…
Browse files Browse the repository at this point in the history
…ome optimization

* Small fix.
* Need to add sf and rename count column.
* Using R's numeric() instead of alloc().
* Update NEWS
* Fixing #63. The issue on M1 Mac is due to implicit conversion of a double (factor) to long int here: on M1 Macs this is rounded downwards, thus I needed to add a small number. Took me 6 freaking hours of simultaneous debugging on Mac and Windows to find it...
* Adding return_sf argument: set to FALSE for memory efficient long datat frame (can be converted to S2 and other classes).
* Appeasing R CMD check.
* Comment and change of notation as requested by @r-barnes.
* Using dgprintf as requested by @r-barnes.
* Update CONTRIBUTING.md to explain C++ workflow
* Also using dgprintf here.
* Install instructions for fork.
* Update README.md
* Remove magrittr pipe.
* Need to add dplyr for vignette it seems.
  • Loading branch information
SebKrantz authored and r-barnes committed May 21, 2024
1 parent 8e73e2e commit 6ff5150
Show file tree
Hide file tree
Showing 17 changed files with 270 additions and 183 deletions.
23 changes: 22 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,25 @@ These parts are:
* `copy_to_src/func_gen.py` - Autogenerates full-factorial coordinate conversion code
* `./update_from_upstream.h` - Copies the appropriate files from `submodules/DGGRID` into `src/`

Why do we have to do this copying? Because R's build model is pretty terrible: it assumes all the code lives in the same directory. If you want a reasonable, subdirectory-based organization of your code things become very painful.
Why do we have to do this copying? Because R's build model is pretty terrible: it assumes all the code lives in the same directory. If you want a reasonable, subdirectory-based organization of your code things become very painful.

Making changes to the C++
==============================================

Updating the C++ code in dggridR is a multi-step process.

1. Pull code from https://github.com/sahrk/DGGRID into https://github.com/r-barnes/DGGRID
2. Update submodules/DGGRID from https://github.com/r-barnes/DGGRID
3. Run ./update_from_upstream.sh to update dggridR/src from submodules/DGGRID

Making fixes to the C++ code requires running this process in reverse. The following workflow is suggested.

1. Make any changes you need to submodules/DGGRID. Use submodules/DGGRID/CMakeLists.txt and the usual CMake workflow to ensure these compile.
2. Use ./update_from_upstream.sh to import your changes into dggridR and test that they work.
3. Iterate on the above until everything is working.
4. If you need changes to CRAN soonish, collect changes to submodules/DGGRID into a branch on r-barnes/DGGRID that submodules/DGGRID can point to.
5. Break changes in submodules/DGGRID apart into small branches on r-barnes/DGGRID which can be made into pull requests to https://github.com/sahrk/DGGRID.
6. Get Kevin Sahr's to approve and merge the PR's into https://github.com/sahrk/DGGRID.
7. Update https://github.com/r-barnes/DGGRID
8. Point submodules/DGGRID to master on https://github.com/r-barnes/DGGRID
9. Run ./update_from_upstream.sh to update dggridR/src from submodules/DGGRID
27 changes: 10 additions & 17 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
Package: dggridR
Type: Package
Title: Discrete Global Grids
Version: 3.0.0
Date: 2023-01-16
Author: Richard Barnes [aut, cre], Kevin Sahr [aut, cph], Gerald Evenden [cph], Angus Johnson [cph], Frank Warmerdam [cph], Even Rouault [cph], Lian Song [ctb]
Version: 3.1.0
Date: 2023-07-10
Author: Richard Barnes [aut, cre], Kevin Sahr [aut, cph], Gerald Evenden [cph], Angus Johnson [cph], Frank Warmerdam [cph], Even Rouault [cph], Lian Song [ctb], Sebastian Krantz [ctb]
Maintainer: Richard Barnes <[email protected]>
NeedsCompilation: yes
Depends: R (>= 3.4.0), dplyr (>= 0.4), rlang (>= 0.4), sf (>= 1.0), sp (>= 1.2)
Suggests: ggplot2,
knitr,
rmarkdown,
maps,
mapproj,
R.rsp,
testthat
Depends: R (>= 3.4.0)
Imports: Rcpp (>= 0.12.12), collapse (>= 1.8.0), sf (>= 1.0), s2 (>= 1.1)
LinkingTo: Rcpp
RcppModules: dgfuncs, gridgens, gridstats
Suggests: ggplot2, dplyr, knitr, rmarkdown, maps, mapproj, R.rsp, testthat
License: AGPL (>= 3)
Authors@R: c(person("Richard", "Barnes", role = c("aut", "cre"), email = "[email protected]"),
person("Kevin", "Sahr", role = c("aut", "cph"), email = "[email protected]"),
person("Gerald", "Evenden", role = "cph"),
person("Angus", "Johnson", role = "cph"),
person("Frank", "Warmerdam", role = "cph"),
person("Even", "Rouault", role = "cph"),
person("Lian", "Song", role = "ctb")
person("Lian", "Song", role = "ctb"),
person("Sebastian", "Krantz", role = "ctb")
)
Description: Spatial analyses involving binning require that every bin have the same area, but this is impossible using a rectangular grid laid over the Earth or over any projection of the Earth. Discrete global grids use hexagons, triangles, and diamonds to overcome this issue, overlaying the Earth with equally-sized bins. This package provides utilities for working with discrete global grids, along with utilities to aid in plotting such data.
URL: https://github.com/r-barnes/dggridR/
BugReports: https://github.com/r-barnes/dggridR/
Imports:
Rcpp (>= 0.12.12),
methods (>= 3.4.0)
LinkingTo: Rcpp
RcppModules: dgfuncs, gridgens, gridstats
RoxygenNote: 7.2.3
Encoding: UTF-8
VignetteBuilder: knitr, R.rsp
Expand Down
22 changes: 13 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ export(dgrectgrid)
export(dgsetres)
export(dgshptogrid)
export(dgverify)
import(dplyr)
import(sf)
import(sp)
importFrom(methods,as)
importFrom(rlang,.data)
importFrom(utils,read.csv)
importFrom(utils,read.table)
importFrom(utils,tail)
importFrom(utils,write.table)
importFrom(Rcpp,loadModule)
importFrom(collapse,fgroup_by)
importFrom(collapse,fmutate)
importFrom(collapse,fsummarise)
importFrom(collapse,funique)
importFrom(collapse,qDF)
importFrom(s2,s2_convex_hull_agg)
importFrom(s2,s2_geog_point)
importFrom(sf,st_as_sf)
importFrom(sf,st_bbox)
importFrom(sf,st_read)
importFrom(sf,write_sf)
importFrom(tools,file_path_sans_ext)
useDynLib(dggridR)
14 changes: 14 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
dggridR v3.1.0
===============
* Fixed a numeric precision issue on Apple silicon computers (#63)
* Removed dplyr, rlang and sp as dependencies to make the package more
lightweight and up to date (sp is depreciated)
* Added collapse and s2 as dependencies (incurring 0 additional dependencies)
yielding significant performance gains, especially in grid materialization
* Function dgshptogrid now also allows passing an sf data frame in memory,
in addition to a shapefile saved to disc
* Functions dgcellstogrid, dgearthgrid, dgrectgrid and dgshptogrid now have an
additional argument return_sf = TRUE. Setting return_sf = FALSE gives a more
memory efficient long data frame with the coordinates of the cell vertices.
* These changes were made by Sebastian Krantz

dggridR v3.0.0 (Release date: 2023-01-02)
===============
* Fixes memory leaks in DGGRID
Expand Down
Loading

0 comments on commit 6ff5150

Please sign in to comment.