-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"hash": "c905e21f89488be81c960ab0cedd6660", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: \"6: duckdb\"\nauthor: Carl Boettiger\ndate: \"2024-03-06\"\n---\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(duckdbfs)\nlibrary(dplyr)\nlibrary(sf)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\n# SQL\n\npad <- open_dataset(\"https://data.source.coop/cboettig/pad-us-3/pad-us3-combined.parquet\")\n\npad_meta <- duckdbfs::st_read_meta(\"https://data.source.coop/cboettig/pad-us-3/pad-us3-combined.fgb\", tblname = \"pad_meta\")\npad_meta\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n# A tibble: 1 × 7\n feature_count geom_column_name geom_type name code wkt proj4\n <dbl> <chr> <chr> <chr> <chr> <chr> <chr>\n1 440107 geom Unknown (any) ESRI 102039 \"PROJCS[\\\"USA… +pro…\n```\n\n\n:::\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\npad |> \n filter(State_Nm == \"CA\") |> \n group_by(FeatClass) |> \n summarise(total_area = sum(SHAPE_Area),\n n = n()) |>\n collect()\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nWarning: Missing values are always removed in SQL aggregation functions.\nUse `na.rm = TRUE` to silence this warning\nThis warning is displayed once every 8 hours.\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stdout}\n\n```\n# A tibble: 5 × 3\n FeatClass total_area n\n <chr> <dbl> <dbl>\n1 Proclamation 173843820097. 324\n2 Easement 7275244842. 11337\n3 Marine 36793465608. 214\n4 Designation 129887995064. 1293\n5 Fee 194547665576. 17873\n```\n\n\n:::\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nduckdbfs::load_spatial()\n```\n:::\n\n\n\nReading in as a normal tibble, and then converting to a spatial object:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nca_fee <- pad |> \n filter(State_Nm == \"CA\", FeatClass == \"Fee\") |> \n collect()\n\nca_fee |> st_as_sf(sf_column_name = \"geometry\", crs = pad_meta$wkt)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nSimple feature collection with 17873 features and 34 fields\nGeometry type: GEOMETRY\nDimension: XY\nBounding box: xmin: -2349024 ymin: 1242361 xmax: -1646723 ymax: 2452203\nProjected CRS: USA_Contiguous_Albers_Equal_Area_Conic_USGS_version\n# A tibble: 17,873 × 35\n FeatClass Category Own_Type Own_Name Loc_Own Mang_Type Mang_Name Loc_Mang\n * <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> \n 1 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 2 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 3 Fee Fee STAT OTHS University… STAT OTHS Univers…\n 4 Fee Fee STAT OTHS University… STAT OTHS Univers…\n 5 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 6 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 7 Fee Fee LOC CITY City of Sa… LOC CITY City of…\n 8 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 9 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n10 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n# ℹ 17,863 more rows\n# ℹ 27 more variables: Des_Tp <chr>, Loc_Ds <chr>, Unit_Nm <chr>, Loc_Nm <chr>,\n# State_Nm <chr>, Agg_Src <chr>, GIS_Src <chr>, Src_Date <chr>,\n# GIS_Acres <int>, Source_PAID <chr>, WDPA_Cd <int>, Pub_Access <chr>,\n# Access_Src <chr>, Access_Dt <chr>, GAP_Sts <chr>, GAPCdSrc <chr>,\n# GAPCdDt <chr>, IUCN_Cat <chr>, IUCNCtSrc <chr>, IUCNCtDt <chr>,\n# Date_Est <chr>, Comments <chr>, EsmtHldr <chr>, EHoldTyp <chr>, …\n```\n\n\n:::\n:::\n\n\nSimilarly, any normal data frame can be coerced to a spatial `sf` object, e.g.:\n\n::: {.cell}\n\n```{.r .cell-code}\ndata.frame(lon = c(1,2), lat=c(0,0)) |> st_as_sf(coords = c(\"lon\", \"lat\"), crs=4326)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nSimple feature collection with 2 features and 0 fields\nGeometry type: POINT\nDimension: XY\nBounding box: xmin: 1 ymin: 0 xmax: 2 ymax: 0\nGeodetic CRS: WGS 84\n geometry\n1 POINT (1 0)\n2 POINT (2 0)\n```\n\n\n:::\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nspatial_ex <- paste0(\"https://raw.githubusercontent.com/cboettig/duckdbfs/\",\n \"main/inst/extdata/spatial-test.csv\") |>\n open_dataset(format = \"csv\") \n\nspatial_ex |>\n mutate(geometry = st_point(longitude, latitude)) |>\n to_sf(crs = 4326)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nSimple feature collection with 10 features and 3 fields\nGeometry type: POINT\nDimension: XY\nBounding box: xmin: 1 ymin: 1 xmax: 10 ymax: 10\nGeodetic CRS: WGS 84\n site latitude longitude geom\n1 a 1 1 POINT (1 1)\n2 b 2 2 POINT (2 2)\n3 c 3 3 POINT (3 3)\n4 d 4 4 POINT (4 4)\n5 e 5 5 POINT (5 5)\n6 f 6 6 POINT (6 6)\n7 g 7 7 POINT (7 7)\n8 h 8 8 POINT (8 8)\n9 i 9 9 POINT (9 9)\n10 j 10 10 POINT (10 10)\n```\n\n\n:::\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nca_fee <- pad |> \n filter(State_Nm == \"CA\", FeatClass == \"Fee\") |> \n group_by(Own_Type) |>\n summarise(total = sum(SHAPE_Area)) |> head(1000) |> collect()\n```\n:::", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"hash": "73ec8608d7eb19954853e754021ef32f", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: \"1: Satellite data\"\nauthor: Carl Boettiger\ndate: \"2024-01-31\"\n---\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(rstac)\nlibrary(gdalcubes)\nlibrary(stars)\nlibrary(tmap)\nlibrary(dplyr)\nearthdatalogin::gdal_cloud_config()\ngdalcubes::gdalcubes_options(parallel = TRUE)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nbox <- c(xmin=-123, ymin=37, xmax=-121, ymax=39) \nstart_date <- \"2022-06-01\"\nend_date <- \"2022-08-01\"\nitems <-\n stac(\"https://earth-search.aws.element84.com/v0/\") |>\n stac_search(collections = \"sentinel-s2-l2a-cogs\",\n bbox = box,\n datetime = paste(start_date, end_date, sep=\"/\"),\n limit = 100) |>\n ext_query(\"eo:cloud_cover\" < 20) |>\n post_request()\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\ncol <- stac_image_collection(items$features, asset_names = c(\"B08\", \"B04\", \"SCL\"))\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nWarning in stac_image_collection(items$features, asset_names = c(\"B08\", : STAC\nasset with name 'SCL' does not include eo:bands metadata and will be considered\nas a single band source\n```\n\n\n:::\n\n```{.r .cell-code}\ncube <- cube_view(srs =\"EPSG:4326\",\n extent = list(t0 = start_date, t1 = end_date,\n left = box[1], right = box[3],\n top = box[4], bottom = box[2]),\n dx = 0.001, dy = 0.001, dt = \"P1M\",\n aggregation = \"median\", resampling = \"average\")\n```\n:::\n\n\n\nThe SCL data layer in Sentinel is one of three 'quality assurance' layers provided in this data catalog. Table 3 in this description of the [Sentinel-2 Level2A Specifications](https://docs.digitalearthafrica.org/en/latest/data_specs/Sentinel-2_Level-2A_specs.html) summarizes the classification codes (Cloud shadows, medium probability cloud, high probability cloud). An image mask basically drops these bad pixels. \n\n\n::: {.cell}\n\n```{.r .cell-code}\nmask <- image_mask(\"SCL\", values=c(3, 8, 9)) # mask clouds and cloud shadows\n\ndata <- raster_cube(col, cube, mask = mask)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nndvi <- data |>\n select_bands(c(\"B04\", \"B08\")) |>\n apply_pixel(\"(B08-B04)/(B08+B04)\", \"NDVI\") |>\n reduce_time(c(\"mean(NDVI)\")) \n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nndvi_stars <- st_as_stars(ndvi)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nmako <- tm_scale_continuous(values = viridisLite::mako(30))\nfill <- tm_scale_continuous(values = \"Greens\")\n\ntm_shape(ndvi_stars) + tm_raster(col.scale = mako)\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nstars object downsampled to 1000 by 1000 cells.\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stderr}\n\n```\nWarning in value[[3L]](cond): could not rename the data.table\n```\n\n\n:::\n\n::: {.cell-output-display}\n![](example-1_files/figure-html/unnamed-chunk-7-1.png){width=672}\n:::\n:::", | ||
"supporting": [ | ||
"example-1_files" | ||
], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"hash": "88091339bf8e900459dc097a700780d5", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: \"3: animations\"\nauthor: Carl Boettiger\ndate: \"2024-02-05\"\n---\n\n\nFollowing the same template, but we compute over a larger bounding box and generate an animation \n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(rstac)\nlibrary(gdalcubes)\nlibrary(stars)\nlibrary(tmap)\nlibrary(dplyr)\nearthdatalogin::gdal_cloud_config()\nearthdatalogin::with_gdalcubes()\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nbox <- c(xmin=-123, ymin=37, xmax=-122, ymax=38) \nstart_date <- \"2022-01-01\"\nend_date <- \"2022-06-30\"\nitems <-\n stac(\"https://planetarycomputer.microsoft.com/api/stac/v1\") |>\n stac_search(collections = \"sentinel-2-l2a\",\n bbox = box,\n datetime = paste(start_date, end_date, sep=\"/\"),\n limit = 1000) |>\n ext_query(\"eo:cloud_cover\" < 20) |>\n post_request() |>\n items_sign(sign_planetary_computer())\n```\n:::\n\n\nLet's do a true-color RGB image this time by combining data from Blue, Green, and Red bands:\n\n\n::: {.cell}\n\n```{.r .cell-code}\ncol <- stac_image_collection(items$features, asset_names = c(\"B02\", \"B03\", \"B04\", \"SCL\"))\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nWarning in stac_image_collection(items$features, asset_names = c(\"B02\", : STAC\nasset with name 'SCL' does not include eo:bands metadata and will be considered\nas a single band source\n```\n\n\n:::\n\n```{.r .cell-code}\ncube <- cube_view(srs =\"EPSG:4326\",\n extent = list(t0 = start_date, t1 = end_date,\n left = box[1], right = box[3],\n top = box[4], bottom = box[2]),\n dx = 0.001, dy = 0.001, dt = \"P1M\")\n\ndata <- raster_cube(col, cube)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nndvi <- data |>\n select_bands(c(\"B02\",\"B03\", \"B04\")) |>\n write_ncdf(\"visual.nc\", overwrite=TRUE)\n```\n:::\n\n\nWhile we could go directly from `apply_pixel` to `animate`, here we show how to stash a copy of the computed, rescaled and reprojected data as a local netcdf file that can be used in any further analysis without going back to the original data. To continue our `gdalcubes` pipeline, we can easily load this space-time ncdf cube and continue as before:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nncdf_cube(\"visual.nc\") |>\n animate(rgb=3:1, \n col = viridisLite::mako, fps=2, \n save_as=\"visual.gif\")\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] \"visual.gif\"\n```\n\n\n:::\n:::\n\n\n\n![](visual.gif)", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"hash": "901b938e0e5d07201bcfbc6b428ce8a3", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: \"4: Biodiversity Intactness Index\"\nauthor: Carl Boettiger\ndate: \"2024-02-07\"\n---\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(rstac)\nlibrary(gdalcubes)\nlibrary(stars)\nlibrary(tmap)\nlibrary(dplyr)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(spData)\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nTo access larger datasets in this package, install the spDataLarge\npackage with: `install.packages('spDataLarge',\nrepos='https://nowosad.github.io/drat/', type='source')`\n```\n\n\n:::\n\n```{.r .cell-code}\nbox_ca <- spData::us_states |> filter(NAME==\"California\") |> st_bbox()\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nbox <- c(xmin=-123, ymin=37, xmax=-121, ymax=39) \nbox <- c(box_ca)\nitems <- \n stac(\"https://planetarycomputer.microsoft.com/api/stac/v1\") |>\n stac_search(collections = \"io-biodiversity\",\n bbox = box,\n limit = 100) |>\n post_request() |>\n items_sign(sign_planetary_computer())\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\ncol <- stac_image_collection(items$features, asset_names = c(\"data\"))\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nWarning in stac_image_collection(items$features, asset_names = c(\"data\")): STAC\nasset with name 'data' does not include eo:bands metadata and will be\nconsidered as a single band source\n```\n\n\n:::\n\n```{.r .cell-code}\ncube <- cube_view(srs =\"EPSG:4326\",\n extent = list(t0 = \"2017-01-01\", t1 = \"2017-12-31\",\n left = box[1], right = box[3],\n top = box[4], bottom = box[2]),\n dx = 0.005, dy = 0.005, dt = \"P1Y\")\n\ndata <- raster_cube(col, cube)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nbii <- data |> slice_time(\"2017-01-01\") |> st_as_stars()\ntm_shape(bii) + tm_raster()\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nstars object downsampled to 1028 by 948 cells.\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stderr}\n\n```\nWarning in value[[3L]](cond): could not rename the data.table\n```\n\n\n:::\n\n::: {.cell-output-display}\n![](example-4_files/figure-html/unnamed-chunk-5-1.png){width=672}\n:::\n:::\n", | ||
"supporting": [ | ||
"example-4_files" | ||
], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
_freeze/tutorials/example-5-fire/execute-results/html.json
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"hash": "c905e21f89488be81c960ab0cedd6660", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: \"6: duckdb\"\nauthor: Carl Boettiger\ndate: \"2024-03-06\"\n---\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(duckdbfs)\nlibrary(dplyr)\nlibrary(sf)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\n# SQL\n\npad <- open_dataset(\"https://data.source.coop/cboettig/pad-us-3/pad-us3-combined.parquet\")\n\npad_meta <- duckdbfs::st_read_meta(\"https://data.source.coop/cboettig/pad-us-3/pad-us3-combined.fgb\", tblname = \"pad_meta\")\npad_meta\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n# A tibble: 1 × 7\n feature_count geom_column_name geom_type name code wkt proj4\n <dbl> <chr> <chr> <chr> <chr> <chr> <chr>\n1 440107 geom Unknown (any) ESRI 102039 \"PROJCS[\\\"USA… +pro…\n```\n\n\n:::\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\npad |> \n filter(State_Nm == \"CA\") |> \n group_by(FeatClass) |> \n summarise(total_area = sum(SHAPE_Area),\n n = n()) |>\n collect()\n```\n\n::: {.cell-output .cell-output-stderr}\n\n```\nWarning: Missing values are always removed in SQL aggregation functions.\nUse `na.rm = TRUE` to silence this warning\nThis warning is displayed once every 8 hours.\n```\n\n\n:::\n\n::: {.cell-output .cell-output-stdout}\n\n```\n# A tibble: 5 × 3\n FeatClass total_area n\n <chr> <dbl> <dbl>\n1 Proclamation 173843820097. 324\n2 Easement 7275244842. 11337\n3 Marine 36793465608. 214\n4 Designation 129887995064. 1293\n5 Fee 194547665576. 17873\n```\n\n\n:::\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nduckdbfs::load_spatial()\n```\n:::\n\n\n\nReading in as a normal tibble, and then converting to a spatial object:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nca_fee <- pad |> \n filter(State_Nm == \"CA\", FeatClass == \"Fee\") |> \n collect()\n\nca_fee |> st_as_sf(sf_column_name = \"geometry\", crs = pad_meta$wkt)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nSimple feature collection with 17873 features and 34 fields\nGeometry type: GEOMETRY\nDimension: XY\nBounding box: xmin: -2349024 ymin: 1242361 xmax: -1646723 ymax: 2452203\nProjected CRS: USA_Contiguous_Albers_Equal_Area_Conic_USGS_version\n# A tibble: 17,873 × 35\n FeatClass Category Own_Type Own_Name Loc_Own Mang_Type Mang_Name Loc_Mang\n * <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> \n 1 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 2 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 3 Fee Fee STAT OTHS University… STAT OTHS Univers…\n 4 Fee Fee STAT OTHS University… STAT OTHS Univers…\n 5 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 6 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 7 Fee Fee LOC CITY City of Sa… LOC CITY City of…\n 8 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n 9 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n10 Fee Fee LOC CITY San Diego,… LOC CITY San Die…\n# ℹ 17,863 more rows\n# ℹ 27 more variables: Des_Tp <chr>, Loc_Ds <chr>, Unit_Nm <chr>, Loc_Nm <chr>,\n# State_Nm <chr>, Agg_Src <chr>, GIS_Src <chr>, Src_Date <chr>,\n# GIS_Acres <int>, Source_PAID <chr>, WDPA_Cd <int>, Pub_Access <chr>,\n# Access_Src <chr>, Access_Dt <chr>, GAP_Sts <chr>, GAPCdSrc <chr>,\n# GAPCdDt <chr>, IUCN_Cat <chr>, IUCNCtSrc <chr>, IUCNCtDt <chr>,\n# Date_Est <chr>, Comments <chr>, EsmtHldr <chr>, EHoldTyp <chr>, …\n```\n\n\n:::\n:::\n\n\nSimilarly, any normal data frame can be coerced to a spatial `sf` object, e.g.:\n\n::: {.cell}\n\n```{.r .cell-code}\ndata.frame(lon = c(1,2), lat=c(0,0)) |> st_as_sf(coords = c(\"lon\", \"lat\"), crs=4326)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nSimple feature collection with 2 features and 0 fields\nGeometry type: POINT\nDimension: XY\nBounding box: xmin: 1 ymin: 0 xmax: 2 ymax: 0\nGeodetic CRS: WGS 84\n geometry\n1 POINT (1 0)\n2 POINT (2 0)\n```\n\n\n:::\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nspatial_ex <- paste0(\"https://raw.githubusercontent.com/cboettig/duckdbfs/\",\n \"main/inst/extdata/spatial-test.csv\") |>\n open_dataset(format = \"csv\") \n\nspatial_ex |>\n mutate(geometry = st_point(longitude, latitude)) |>\n to_sf(crs = 4326)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nSimple feature collection with 10 features and 3 fields\nGeometry type: POINT\nDimension: XY\nBounding box: xmin: 1 ymin: 1 xmax: 10 ymax: 10\nGeodetic CRS: WGS 84\n site latitude longitude geom\n1 a 1 1 POINT (1 1)\n2 b 2 2 POINT (2 2)\n3 c 3 3 POINT (3 3)\n4 d 4 4 POINT (4 4)\n5 e 5 5 POINT (5 5)\n6 f 6 6 POINT (6 6)\n7 g 7 7 POINT (7 7)\n8 h 8 8 POINT (8 8)\n9 i 9 9 POINT (9 9)\n10 j 10 10 POINT (10 10)\n```\n\n\n:::\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nca_fee <- pad |> \n filter(State_Nm == \"CA\", FeatClass == \"Fee\") |> \n group_by(Own_Type) |>\n summarise(total = sum(SHAPE_Area)) |> head(1000) |> collect()\n```\n:::", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.