Code Monkey home page Code Monkey logo

sabre's Introduction

sabre

CRAN status R-CMD-check codecov CRAN RStudio mirror downloads

The sabre (Spatial Association Between REgionalizations) is an R package for calculating a degree of spatial association between regionalizations or categorical maps. This package offers support for sf, RasterLayer, SpatRaster, and stars spatial objects, and the following methods:

  • the V-measure method (Nowosad and Stepinski, 2018)
  • the MapCurve method (Hargrove et al., 2006)

Installation

You can install the released version of sabre from CRAN with:

install.packages("sabre")

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("Nowosad/sabre")

Example

We use two simple regionalization, regions1 and regions2 to show the basic concept of calculating a degree of spatial association.

library(sabre)
library(sf)
data("regions1")
data("regions2")

The first map, regions1 consists of four regions of the same shape and size, while the second one, regions2 has three irregular regions.

The vmeasure_calc() function allows for calculation of a degree of spatial association between regionalizations or categorical maps using the information-theoretical V-measure. It requires, at least, four arguments:

  • x - an sf object containing the first regionalization
  • x_name - a name of the column with regions names of the first regionalization
  • y - an sf object containing the second regionalization
  • y_name - a name of the column with regions names of the second regionalization
regions_vm = vmeasure_calc(x = regions1, y = regions2, x_name = z, y_name = z)

The result is a list with three metrics of spatial association - V-measure, Homogeneity, Completeness - and two sf objects with preprocessed input maps - $map1 and $map2.

regions_vm
#> The SABRE results:
#> 
#>  V-measure: 0.36 
#>  Homogeneity: 0.32 
#>  Completeness: 0.42 
#> 
#>  The spatial objects can be retrieved with:
#>  $map1 - the first map
#>  $map2 - the second map

Both spatial outputs have two columns. The first one contains regions’ names/values and the second one (rih) describes regions’ inhomogeneities.

plot(regions_vm$map1["rih"], main = "Map1: rih")
plot(regions_vm$map2["rih"], main = "Map2: rih")

More examples can be found in the package vignette and in the sabre: or how to compare two maps? blog post.

Logo

Hex logo was created with hexmake using icons made by Smashicons and Creaticca Creative Agency from www.flaticon.com.

References

  • Nowosad, Jakub, and Tomasz F. Stepinski. “Spatial association between regionalizations using the information-theoretical V-measure.” International Journal of Geographical Information Science (2018). https://doi.org/10.1080/13658816.2018.1511794
  • Rosenberg, Andrew, and Julia Hirschberg. “V-measure: A conditional entropy-based external cluster evaluation measure.” Proceedings of the 2007 joint conference on empirical methods in natural language processing and computational natural language learning (EMNLP-CoNLL). 2007.
  • Hargrove, William W., Forrest M. Hoffman, and Paul F. Hessburg. “Mapcurves: a quantitative method for comparing categorical maps.” Journal of Geographical Systems 8.2 (2006): 187.

sabre's People

Contributors

katiejolly avatar nowosad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sabre's Issues

GEOS-devel issues with OverlayNG

With GEOS devel version installed with --enable-overlayng, I see a failure in sf_intersection(). Here is the log and a zipfile of an rda file with objects sabre_x and sabre_y. Could you please check with released GEOS, then build sf and GDAL against GEOS built with --enable-overlayng, say from a recent nightly bz-ball, and report back? See also r-spatial/sf#794.

sabre_00check.log
GEOS_dev_issue.zip

Note that I'm also using GDAL 3.2.0 RC1, so the OGR: Corrupt data may be from GDAL rather than GEOS. I see a very similar error in the 'siland* package (not on github), logfile here:
siland_00check.log. If you get test containers up, debugging that error may help pin down the problem. If it is GDAL, feedback before 3.2.0 is released would help!

European data missing from blog post

Hi Jakub,

I am interested in reproducing the blog post you on your website have showcasing the sabre package and cannot seem to download the European boundary data from the SIL website. The data doesn't seem to be found at the following url - http://sil.uc.edu/cms/data/uploads/software_data/vmeasure/regions.zip
Is there another resource for this zip?

Thanks,
Lawrence

consistent interfaces with spatialclustering package

hey @Nowosad Just to let you know I'm developing a spatialcluster package which is a nice complement to sabre and vice-versa. spatialcluster currently takes entirely general input, but it'll be extended to spatial input soon. Current output is a custom class. Minimal functionality should all be in place next week. As part of that, i/we should ensure that spatialcluster and sabre interface as seamlessly as possible. I'd love to hear any thoughts you might have in that regard - suggest spatialcluster modifications in cross issue there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.