@@ -74,9 +74,8 @@ res_extensive <- ddbs_interpolate_aw(
7474 sid = " source_id" ,
7575 extensive = " BIR74" ,
7676 weight = " total" ,
77- output = " sf"
77+ mode = " sf"
7878)
79- # > ✔ Query successful
8079```
8180
8281** Verification:** The total sum of births in the result should match the
@@ -106,9 +105,8 @@ res_intensive <- ddbs_interpolate_aw(
106105 sid = " source_id" ,
107106 intensive = " BIR74" , # Treated as density here
108107 weight = " sum" , # Standard behavior for intensive vars
109- output = " sf"
108+ mode = " sf"
110109)
111- # > ✔ Query successful
112110```
113111
114112### Visual Comparison
@@ -135,8 +133,9 @@ plot(plot_data[c("Extensive_Count", "Intensive_Value")],
135133
136134If you are working with massive datasets, constructing the geometry for
137135the result ` sf ` object can be slow. If you only need the interpolated
138- numbers, set ` output = "tibble" ` . This skips the geometry construction
139- step and is significantly faster.
136+ numbers, collect the default ` duckspatial_df ` using
137+ ` ddbs_collect(as = "tibble") ` . This skips the geometry construction step
138+ and is significantly faster.
140139
141140``` r
142141# Return a standard data.frame/tibble without geometry
@@ -145,21 +144,20 @@ res_tbl <- ddbs_interpolate_aw(
145144 source = nc ,
146145 tid = " target_id" ,
147146 sid = " source_id" ,
148- extensive = " BIR74" ,
149- output = " tibble"
150- )
151- # > ✔ Query successful
147+ extensive = " BIR74"
148+ ) | >
149+ ddbs_collect(as = " tibble" )
152150
153151head(res_tbl )
154- # > # A tibble: 6 × 3
155- # > target_id crs_duckspatial BIR74
156- # > <int> <chr> < dbl>
157- # > 1 1 EPSG:5070 1168.
158- # > 2 2 EPSG:5070 379.
159- # > 3 6 EPSG:5070 753.
160- # > 4 7 EPSG:5070 5731.
161- # > 5 8 EPSG:5070 8000.
162- # > 6 11 EPSG:5070 1417.
152+ # > # A tibble: 6 × 2
153+ # > target_id BIR74
154+ # > <int> <dbl>
155+ # > 1 1 1168.
156+ # > 2 2 379.
157+ # > 3 6 753.
158+ # > 4 7 5731.
159+ # > 5 8 8000.
160+ # > 6 11 1417.
163161```
164162
165163## 3) Database Mode: Large Data Workflows
@@ -248,7 +246,7 @@ ddbs_interpolate_aw(
248246 weight = " total" ,
249247 name = " nc_grid_births" , # <--- Writes to DB
250248 overwrite = TRUE ,
251- output = " tibble"
249+ mode = " tibble"
252250)
253251# > ℹ Table <nc_grid_births> dropped
254252# > ✔ Query successful
@@ -257,13 +255,29 @@ ddbs_interpolate_aw(
257255And preview this table directly in the database:
258256
259257``` r
260- DBI :: dbGetQuery(conn , " SELECT * FROM nc_grid_births LIMIT 5" )
261- # > target_id crs_duckspatial BIR74
262- # > 1 1 EPSG:5070 1168.3093
263- # > 2 2 EPSG:5070 378.5281
264- # > 3 6 EPSG:5070 752.9156
265- # > 4 7 EPSG:5070 5731.0103
266- # > 5 8 EPSG:5070 7999.6957
258+ as_duckspatial_df(" nc_grid_births" , conn )
259+ # > # A duckspatial lazy spatial table
260+ # > # ● CRS: EPSG:5070
261+ # > # ● Geometry column: x
262+ # > # ● Geometry type: POLYGON
263+ # > # ● Bounding box: xmin: 1.0543e+06 ymin: 1.348e+06 xmax: 1.8335e+06 ymax: 1.6892e+06
264+ # > # Data backed by DuckDB (dbplyr lazy evaluation)
265+ # > # Use ddbs_collect() or st_as_sf() to materialize to sf
266+ # > #
267+ # > # Source: SQL [?? x 3]
268+ # > # Database: DuckDB 1.5.0 [unknown@Linux 6.14.0-1017-azure:R 4.5.3/:memory:]
269+ # > target_id x BIR74
270+ # > <int> <list> <dbl>
271+ # > 1 1 <raw [93]> 1168.
272+ # > 2 2 <raw [93]> 379.
273+ # > 3 6 <raw [93]> 753.
274+ # > 4 7 <raw [93]> 5731.
275+ # > 5 8 <raw [93]> 8000.
276+ # > 6 11 <raw [93]> 1417.
277+ # > 7 12 <raw [93]> 8314.
278+ # > 8 13 <raw [93]> 8305.
279+ # > 9 14 <raw [93]> 25694.
280+ # > 10 15 <raw [93]> 17277.
267281```
268282
269283### Cleanup
0 commit comments