Skip to content

Commit f011ea1

Browse files
committed
Release v0.1.0: Complete hexsmoothR package with documentation
- Updated LICENSE with custom copyright for Max M. Lang - Rebuilt package with proper license configuration - Added comprehensive pkgdown documentation website - Included favicons and proper branding - Updated README and package metadata - Added GitHub Actions workflow for automated documentation - Complete vignette with examples and usage guide
1 parent 926faa1 commit f011ea1

20 files changed

Lines changed: 2163 additions & 119 deletions

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ Thumbs.db
2626
^Meta$
2727
^cran-comments\.md$
2828
^\.github$
29+
^_pkgdown\.yml$
30+
^docs$
31+
^pkgdown$

.github/workflows/pkgdown.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
11+
name: pkgdown.yaml
12+
13+
permissions: read-all
14+
15+
jobs:
16+
pkgdown:
17+
runs-on: ubuntu-latest
18+
# Only restrict concurrency for non-PR jobs
19+
concurrency:
20+
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
21+
env:
22+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
23+
permissions:
24+
contents: write
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: r-lib/actions/setup-pandoc@v2
29+
30+
- uses: r-lib/actions/setup-r@v2
31+
with:
32+
use-public-rspm: true
33+
34+
- uses: r-lib/actions/setup-r-dependencies@v2
35+
with:
36+
extra-packages: any::pkgdown, local::.
37+
needs: website
38+
39+
- name: Build site
40+
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
41+
shell: Rscript {0}
42+
43+
- name: Deploy to GitHub pages 🚀
44+
if: github.event_name != 'pull_request'
45+
uses: JamesIves/github-pages-deploy-action@v4.5.0
46+
with:
47+
clean: false
48+
branch: gh-pages
49+
folder: docs

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ src/RcppExports.cpp
1919
src/RcppExports.R
2020

2121
# Documentation build artifacts
22-
inst/doc/
2322
vignettes/*.html
2423
vignettes/*.pdf
2524

@@ -80,3 +79,4 @@ output/
8079

8180
# Version control
8281
/.git/
82+
docs

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Description: Creates hexagonal grids and applies spatial smoothing to satellite
1111
Gaussian-weighted spatial smoothing using C++ optimization. The package implements
1212
a two-step workflow for spatial analysis: (1) extract raster data into hexagonal grids,
1313
and (2) apply spatial smoothing with customizable neighborhood weights.
14-
License: MIT + file LICENSE
14+
License: file LICENSE
1515
Encoding: UTF-8
1616
Depends: R (>= 4.0.0)
1717
LinkingTo: Rcpp
@@ -29,4 +29,4 @@ Suggests:
2929
VignetteBuilder: knitr
3030
RoxygenNote: 7.3.2
3131
SystemRequirements: GDAL (>= 3.0), GEOS (>= 3.8), PROJ (>= 6.0)
32-
32+
URL: https://maxmlang.github.io/hexsmoothR/

LICENSE

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
MIT License
1+
Copyright (c) 2024, hexsmoothR Max M. Lang
2+
All rights reserved.
23

3-
Copyright (c) 2024 hexsmoothR contributors
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
45

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:
6+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
117

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
8+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
149

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.
10+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11+
12+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT of THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# hexsmoothR: Hexagonal Grid Smoothing for Satellite Data
22

33
<div align="center">
4-
<img src="inst/images/hexsmoothR_sticker.png" alt="hexsmoothR hex sticker" width="200">
4+
<img src="man/figures/hexsmoothR_sticker.png" alt="hexsmoothR hex sticker" width="200">
55
</div>
66

77
<!-- badges: start -->
@@ -65,21 +65,20 @@ library(sf)
6565
library(terra)
6666

6767
# Create hexagonal grid
68-
hex_grid <- create_grid(study_area, cell_size = 0.01, type = "hexagonal")
68+
hex_grid <- create_grid(study_area, cell_size = 20000, type = "hexagonal")
6969

7070
# Compute spatial topology
7171
topology <- compute_topology(hex_grid)
7272

7373
# Extract raster data
7474
raster_files <- c(ndvi = "path/to/ndvi.tif", elevation = "path/to/elevation.tif")
75-
extracted_data <- extract_raster_data(raster_files, study_area, cell_size = 10000)
75+
extracted_data <- extract_raster_data(raster_files, study_area, cell_size = 20000)
7676

7777
# Apply spatial smoothing
7878
smoothed_results <- smooth_variables(
79-
variable_values = list(ndvi = extracted_data$ndvi, elevation = extracted_data$elevation),
80-
first_neighbors = topology$first_order_neighbors,
81-
second_neighbors = topology$second_order_neighbors,
82-
weights = c(1.0, 0.5, 0.25),
79+
variable_values = list(ndvi = extracted_data$data$ndvi, elevation = extracted_data$data$elevation),
80+
neighbors = topology$neighbors,
81+
weights = topology$weights,
8382
var_names = c("ndvi", "elevation")
8483
)
8584
```
@@ -120,37 +119,39 @@ grid <- st_sf(
120119

121120
## Output
122121

123-
The result is an `sf` object with:
124-
- **Raw values**: `{variable}_raw` (extracted raster values)
125-
- **Neighbor averages**: `{variable}_neighbors_1st` (1st order neighbors), `{variable}_neighbors_2nd` (2nd order neighbors)
126-
- **Smoothed values**: `{variable}_smoothed_1st` (weighted 1st order), `{variable}_smoothed_all` (weighted all neighbors)
127-
- **Grid info**: `grid_id`, `grid_index`, `geometry`
128-
129-
Ready for plotting with `ggplot2` or other spatial tools.
122+
The smoothing results contain:
123+
- `raw` - Weighted average of center cell and all neighbors
124+
- `neighbors_1st`, `neighbors_2nd`, etc. - Mean of neighbors at each order
125+
- `weighted_combined` - Final weighted average (recommended for analysis)
130126

131127
## Advanced Usage
132128

133129
### Multiple Variables
134130
```r
135131
raster_files <- c(ndvi = "path/to/ndvi.tif", elevation = "path/to/elevation.tif")
136-
extracted_data <- extract_raster_data(raster_files, study_area, cell_size = 10000)
132+
extracted_data <- extract_raster_data(raster_files, study_area, cell_size = 20000)
137133

138134
smoothed_results <- smooth_variables(
139-
variable_values = list(ndvi = extracted_data$ndvi, elevation = extracted_data$elevation),
140-
first_neighbors = topology$first_order_neighbors,
141-
second_neighbors = topology$second_order_neighbors,
142-
weights = c(1.0, 0.5, 0.25),
135+
variable_values = list(ndvi = extracted_data$data$ndvi, elevation = extracted_data$data$elevation),
136+
neighbors = topology$neighbors,
137+
weights = topology$weights,
143138
var_names = c("ndvi", "elevation")
144139
)
145140
```
146141

147142
### Custom Weights
148143
```r
149-
topology <- compute_topology(hex_grid, sigma = 1000, center_weight = 1.0, first_order_weight = 0.5, second_order_weight = 0.25)
144+
topology <- compute_topology(hex_grid, neighbor_orders = 3, center_weight = 1.0)
150145
```
151146

152147
## Grid Requirements
153148

149+
hexsmoothR works with any hexagonal grid that follows the required structure. You can use grids created with:
150+
151+
- **Uber H3 grids** from Python, R, or any programming language
152+
- **Custom hexagonal grids** created with any GIS software
153+
- **Grids from other packages** (as long as they follow the structure below)
154+
154155
**Required grid structure:**
155156
```r
156157
grid <- st_sf(
@@ -160,10 +161,22 @@ grid <- st_sf(
160161
)
161162
```
162163

163-
**Compatible with:**
164-
- Uber H3 grids from Python/R
165-
- Custom hexagonal grids
166-
- Square grids (for comparison)
164+
**Example with H3 grids from Python:**
165+
```python
166+
import h3
167+
import geopandas as gpd
168+
from shapely.geometry import Polygon
169+
170+
# Create H3 hexagons in Python
171+
h3_hexes = h3.polygon_to_cells(polygon, resolution=8)
172+
geometries = [Polygon(h3.cell_to_boundary(hex_id)) for hex_id in h3_hexes]
173+
174+
# Convert to GeoDataFrame with required structure
175+
gdf = gpd.GeoDataFrame({
176+
'grid_id': h3_hexes,
177+
'grid_index': range(len(h3_hexes))
178+
}, geometry=geometries, crs='EPSG:4326')
179+
```
167180

168181
**Tip:** Use projected CRS (UTM) for real-world analysis with cell sizes in meters.
169182

@@ -175,12 +188,7 @@ grid <- st_sf(
175188

176189
## Implementation Details
177190

178-
hexsmoothR uses Rcpp for high-performance spatial smoothing algorithms with automatic fallback to R implementation if needed. The package provides:
179-
180-
- **C++ optimization**: Multi-variable processing in single pass
181-
- **Memory efficiency**: Contiguous array operations for large datasets
182-
- **Automatic fallback**: R implementation when C++ is unavailable
183-
- **Progress reporting**: For long-running operations
191+
hexsmoothR uses Rcpp for high-performance spatial smoothing algorithms with automatic fallback to R implementation if needed.
184192

185193
## Dependencies
186194

@@ -198,14 +206,6 @@ hexsmoothR uses Rcpp for high-performance spatial smoothing algorithms with auto
198206
2. **Restart R/RStudio** after installing Rtools
199207
3. **Verify installation**: Run `Sys.which("make")` - it should return a path, not `""`
200208

201-
**Alternative for Windows users who can't compile:**
202-
- Use the package on systems with build tools available
203-
- Consider using RStudio Cloud or similar cloud-based R environments
204-
- Contact the maintainer for pre-compiled binaries if available
205-
206-
**Windows Diagnostic Tool:**
207-
Run `source("windows_check.R")` to diagnose your build environment setup.
208-
209209
## Contributing
210210

211211
1. Fork the repository

_pkgdown.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
url: https://maxmlang.github.io/hexsmoothR/
2+
template:
3+
bootstrap: 5
4+

cran-comments.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)