Created
March 28, 2025 22:18
-
-
Save JosiahParry/b5e06cfed66157b742deecf72b53bb3e to your computer and use it in GitHub Desktop.
Creating GeoParquet for Google BigQuery
This file contains hidden or 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
library(arrow) | |
library(geoarrow) | |
library(sf) | |
# following example here: https://geoarrow.org/geoarrow-r/index.html | |
nc <- read_sf(system.file("gpkg/nc.gpkg", package = "sf")) | |
tf <- tempfile(fileext = ".parquet") | |
# this creates a GeoParquet file | |
nc |> | |
# only supported CRS by BigQuery | |
# see https://cloud.google.com/bigquery/docs/geospatial-data#loading_geoparquet_files | |
sf::st_transform(4326) |> | |
tibble::as_tibble() |> | |
write_parquet(tf) | |
# if you open the dataset you can see the `geom` field | |
# has a metadata schema for geoarrow.multipolygon | |
arrow::open_dataset(tf) | |
# you can now use bigrquery to upload the parquet file as a table | |
# https://bigrquery.r-dbi.org/reference/api-perform.html?q=parquet#arguments | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment