Skip to content

Commit d53f8bb

Browse files
committed
Initial release: hexsmoothR - Hexagonal Grid Smoothing for Satellite Data
A comprehensive R package for creating hexagonal grids and applying spatial smoothing to satellite raster data. Features C++ optimization, chunking support for large datasets, and flexible Gaussian weight parameters for spatial analysis.
0 parents  commit d53f8bb

35 files changed

Lines changed: 3568 additions & 0 deletions

.Rbuildignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Hidden files and directories
2+
.git
3+
.gitignore
4+
.Rcheck
5+
hexsmoothR.Rcheck
6+
7+
# Build artifacts
8+
.*\.tar\.gz$
9+
.*\.zip$
10+
11+
# Documentation build artifacts
12+
docs/
13+
14+
# IDE files
15+
.vscode/
16+
.idea/
17+
18+
# OS files
19+
.DS_Store
20+
Thumbs.db
21+
22+
# Temporary files
23+
.*\.tmp$
24+
.*\.temp$
25+
^doc$
26+
^Meta$
27+
^cran-comments\.md$
28+
^\.github$

.github/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.html

.github/workflows/R-CMD-check.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
8+
name: R-CMD-check.yaml
9+
10+
permissions: read-all
11+
12+
jobs:
13+
R-CMD-check:
14+
runs-on: ${{ matrix.config.os }}
15+
16+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
config:
22+
- {os: macos-latest, r: 'release'}
23+
- {os: windows-latest, r: 'release'}
24+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
25+
- {os: ubuntu-latest, r: 'release'}
26+
- {os: ubuntu-latest, r: 'oldrel-1'}
27+
28+
env:
29+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
30+
R_KEEP_PKG_SOURCE: yes
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- uses: r-lib/actions/setup-pandoc@v2
36+
37+
- uses: r-lib/actions/setup-r@v2
38+
with:
39+
r-version: ${{ matrix.config.r }}
40+
http-user-agent: ${{ matrix.config.http-user-agent }}
41+
use-public-rspm: true
42+
43+
- uses: r-lib/actions/setup-r-dependencies@v2
44+
with:
45+
extra-packages: any::rcmdcheck
46+
needs: check
47+
48+
- uses: r-lib/actions/check-r-package@v2
49+
with:
50+
upload-snapshots: true
51+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

.gitignore

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# R package build artifacts
2+
*.tar.gz
3+
*.tgz
4+
*.zip
5+
*.Rcheck/
6+
*.RData
7+
*.Rhistory
8+
*.Rapp.history
9+
10+
# Compiled C++ files
11+
src/*.o
12+
src/*.so
13+
src/*.dll
14+
src/*.dylib
15+
src/symbols.rds
16+
17+
# Rcpp generated files
18+
src/RcppExports.cpp
19+
src/RcppExports.R
20+
21+
# Documentation build artifacts
22+
inst/doc/
23+
vignettes/*.html
24+
vignettes/*.pdf
25+
26+
# Test results
27+
tests/testthat/_snaps/
28+
tests/testthat/testthat.Rout
29+
30+
# RStudio files
31+
.Rproj.user/
32+
.Rhistory
33+
.RData
34+
.Ruserdata
35+
36+
# macOS files
37+
.DS_Store
38+
.AppleDouble
39+
.LSOverride
40+
41+
# Windows files
42+
Thumbs.db
43+
ehthumbs.db
44+
Desktop.ini
45+
46+
# Linux files
47+
*~
48+
49+
# Temporary files
50+
*.tmp
51+
*.temp
52+
*.swp
53+
*.swo
54+
55+
# Output directories
56+
quick_start_results/
57+
temp/
58+
output/
59+
60+
# Generated files
61+
*.jpg
62+
*.jpeg
63+
64+
# Keep the hex sticker for README
65+
!inst/images/hexsmoothR_sticker.png
66+
67+
# Log files
68+
*.log
69+
*.out
70+
71+
# Backup files
72+
*.bak
73+
*.backup
74+
75+
# Package build artifacts
76+
/doc/
77+
/Meta/
78+
/hexsmoothR.Rcheck/
79+
/hexsmoothR_*.tar.gz
80+
81+
# Version control
82+
/.git/

DESCRIPTION

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Package: hexsmoothR
2+
Type: Package
3+
Title: Hexagonal Grid Smoothing for Satellite Data
4+
Version: 0.1.0
5+
Authors@R:
6+
person("Max M.", "Lang", email = "max.lang@stx.ox.ac.uk", role = c("aut", "cre"))
7+
Author: Max M. Lang [aut, cre]
8+
Maintainer: Max M. Lang <max.lang@stx.ox.ac.uk>
9+
Description: Creates hexagonal grids and applies spatial smoothing to satellite raster data.
10+
Provides tools for extracting environmental variables from TIF files and applying
11+
Gaussian-weighted spatial smoothing using C++ optimization. The package implements
12+
a two-step workflow for spatial analysis: (1) extract raster data into hexagonal grids,
13+
and (2) apply spatial smoothing with customizable neighborhood weights.
14+
License: MIT + file LICENSE
15+
Encoding: UTF-8
16+
LazyData: true
17+
Depends: R (>= 4.0.0)
18+
LinkingTo: Rcpp
19+
Imports:
20+
Rcpp,
21+
sf (>= 1.0.0),
22+
terra (>= 1.6.0),
23+
exactextractr (>= 0.8.0),
24+
data.table (>= 1.14.0)
25+
Suggests:
26+
testthat (>= 3.0.0),
27+
knitr,
28+
rmarkdown,
29+
Matrix,
30+
ggplot2,
31+
gridExtra
32+
VignetteBuilder: knitr
33+
RoxygenNote: 7.3.2
34+
SystemRequirements: GDAL (>= 3.0), GEOS (>= 3.8), PROJ (>= 6.0)
35+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 hexsmoothR contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NAMESPACE

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(compute_topology)
4+
export(create_grid)
5+
export(extract_raster_data)
6+
export(find_hex_cell_size_for_target_cells)
7+
export(get_utm_crs)
8+
export(hex_circumradius_to_flat)
9+
export(hex_edge_to_flat)
10+
export(hex_flat_to_circumradius)
11+
export(hex_flat_to_edge)
12+
export(smooth_variables)
13+
importFrom(exactextractr,exact_extract)
14+
importFrom(sf,st_bbox)
15+
importFrom(sf,st_centroid)
16+
importFrom(sf,st_coordinates)
17+
importFrom(sf,st_crop)
18+
importFrom(sf,st_crs)
19+
importFrom(sf,st_distance)
20+
importFrom(sf,st_geometry)
21+
importFrom(sf,st_geometry_type)
22+
importFrom(sf,st_intersection)
23+
importFrom(sf,st_make_grid)
24+
importFrom(sf,st_touches)
25+
importFrom(sf,st_transform)
26+
importFrom(terra,crop)
27+
importFrom(terra,crs)
28+
importFrom(terra,ext)
29+
importFrom(terra,ncell)
30+
importFrom(terra,rast)
31+
importFrom(terra,res)
32+
importFrom(terra,vect)

R/RcppExports.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
2+
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
3+
4+
process_district_all_vars <- function(variable_values, first_neighbors, second_neighbors, weights, hex_indices, var_names) {
5+
.Call('_hexsmoothR_process_district_all_vars', PACKAGE = 'hexsmoothR', variable_values, first_neighbors, second_neighbors, weights, hex_indices, var_names)
6+
}
7+
8+
simple_smoothing_single_var <- function(values, first_neighbors, second_neighbors, hex_indices) {
9+
.Call('_hexsmoothR_simple_smoothing_single_var', PACKAGE = 'hexsmoothR', values, first_neighbors, second_neighbors, hex_indices)
10+
}
11+
12+
gaussian_smoothing_single_var <- function(values, first_neighbors, second_neighbors, center_weight, first_order_weight, second_order_weight, hex_indices) {
13+
.Call('_hexsmoothR_gaussian_smoothing_single_var', PACKAGE = 'hexsmoothR', values, first_neighbors, second_neighbors, center_weight, first_order_weight, second_order_weight, hex_indices)
14+
}
15+

0 commit comments

Comments
 (0)