{"id":18722515,"url":"https://github.com/mdsumner/spex","last_synced_at":"2025-04-12T14:53:04.257Z","repository":{"id":56936223,"uuid":"67215953","full_name":"mdsumner/spex","owner":"mdsumner","description":"Spatial extent tools","archived":false,"fork":false,"pushed_at":"2020-09-29T13:59:13.000Z","size":648,"stargazers_count":21,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T07:46:44.269Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://mdsumner.github.io/spex/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdsumner.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-02T11:06:58.000Z","updated_at":"2023-02-06T16:10:44.000Z","dependencies_parsed_at":"2022-08-21T06:20:45.909Z","dependency_job_id":null,"html_url":"https://github.com/mdsumner/spex","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fspex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fspex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fspex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fspex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdsumner","download_url":"https://codeload.github.com/mdsumner/spex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586228,"owners_count":21128995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T13:41:48.094Z","updated_at":"2025-04-12T14:53:04.221Z","avatar_url":"https://github.com/mdsumner.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\n```\n\n\u003c!-- badges: start --\u003e\n[![Travis-CI Build Status](https://travis-ci.org/mdsumner/spex.svg?branch=master\u0026env=BUILD_NAME=xenial_release\u0026label=linux)](https://travis-ci.org/mdsumner/spex)\n[![Build Status](https://travis-ci.org/mdsumner/spex.svg?branch=master\u0026env=BUILD_NAME=osx_release\u0026label=osx)](https://travis-ci.org/mdsumner/spex)\n[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/mdsumner/spex?branch=master\u0026svg=true)](https://ci.appveyor.com/project/mdsumner/spex)\n[![Coverage status](https://codecov.io/gh/mdsumner/spex/branch/master/graph/badge.svg)](https://codecov.io/github/mdsumner/spex?branch=master)\n[![lifecycle](https://img.shields.io/badge/lifecycle-stable-green.svg)](https://www.tidyverse.org/lifecycle/#stable) \n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/spex)](https://cran.r-project.org/package=spex)\n[![CRAN_Download_Badge](http://cranlogs.r-pkg.org/badges/spex)](https://cran.r-project.org/package=spex)\n[![R build status](https://github.com/mdsumner/spex/workflows/R-CMD-check/badge.svg)](https://github.com/mdsumner/spex/actions)\n\u003c!-- badges: end --\u003e\n  \n## spex\n\nSpex provides a small set of functions for working with spatial data. These are\n\n* `spex()` - a spatial extent with projection metadata\n* `polygonize()` - a fast quadmesh-based pixel-to-polygon translation \n* `buffer_extent` - a convenience function for tidy extents\n* `xlim`, `ylim` - convenience functions for the axes of an extent\n* `extent()` - convenience functions for sf objects\n* `latmask()` - mask a raster based on a latitude\n* `latitudecircle()` - create a spatial region based on a latitude\n\nCreate a fully-fledged SpatialPolygonsDataFrame *extent* from any object understood\nby the 'raster' package function 'extent()'. If the input has projection metadata it\nwill be carried through to the output. The intention is to support any object from packages `sp`, `raster` and `sf`. If you want this to work on other types, [create an issue and get in touch to discuss!](https://github.com/mdsumner/spex/issues). \n\nThe polygonization approach is faster than `rasterToPolygons`, and multi-layer rasters are converted to multi-column spatial data frames. This only does the pixel-to-polygon case. It provides an `sf` POLYGON data frame, but there is a version `qm_rasterToPolygons_sp` that returns a Spatial version. \n\nThe \"buffered extent\" is used to create cleanly aligned extents, useful for generating exacting grid structures\nas raster or vector. \n\n## Installation\n\nInstall 'spex' from CRAN. \n\n```{r,eval=FALSE}\ninstall.packages(\"spex\")\n```\n\n## Examples\n\nCreate a Spatial object as a single extent polygon from a raster. \n\n```{r}\nlibrary(spex)\nlibrary(raster)\ndata(lux)\n(exlux \u003c- spex(lux))\n\n## put an extent and a CRS together\nspex(extent(0, 1, 0, 1), crs = \"+proj=laea +ellps=WGS84\")\n```\n\nCreate a simple features POLYGON data frame from a raster. \n\n```{r}\nlibrary(spex)\nlibrary(raster)\nr \u003c- raster(volcano)\ntm \u003c- system.time(p \u003c- qm_rasterToPolygons(r))\n\np1 \u003c- polygonize(r)\n\nidentical(p, p1)\n \np3 \u003c- qm_rasterToPolygons_sp(r)\nclass(p3)\n\nnrow(p)\n\nclass(p)\n\nclass(p$geometry)\n\nprint(tm)\n```\n\nCreate a buffered extent with whole-number aligned edges. \n\n```{r}\nlibrary(spex)\n\n(ex \u003c- extent(lux))\n\nbuffer_extent(ex, 10)\n\nbuffer_extent(ex, 2)\n```\n\nThere are convenience functions for sf objects. \n\n```{r}\nclass(psf)\nextent(psf)\nspex(psf)\n\n```\n\n\n---\n\nPlease note that this project is released with a [Contributor Code of Conduct](https://hypertidy.github.io/reproj/CODE_OF_CONDUCT.html). By participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2Fspex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdsumner%2Fspex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2Fspex/lists"}