Open source geometry on the sphere using S2 Geometry and R
2021-09-30, 16:00–16:30, Buenos Aires

Whereas many vector processing algorithms require coordinates to be in projected coordinates, processing algorithms are often needed, or simply more convenient, in a global context. Several open source projects currently compute for instance areas from ellipsoidal coordinates by simply assuming they are Cartesian, resulting in meaningless ("squared degree") quantities, without warning. Google's open source S2 Geometry library provides data structures and algorithms for manipulating vector geometry on the sphere; however, its use in open-source GIS software is limited. In addition to most simple feature access operators, S2 Geometry allows for "semi-open" polygons, which uniquely assigns points on boundaries of two touching polygons to a single polygon. This is a welcome addition to DE-9IM for the common case where sets of polygons represent a coverage. In 2020 we created a set of bindings for S2 Geometry in R to add sphere-native capabilities to the sf package, whose functions were previously powered by GEOS for both projected and spherical coordinates. Our bindings reconciled a number of differences between S2 Geometry's C++ API and GEOS' C API that were needed for a seamless transition for users of sf. In addition to eliminating the need for projected coordinates for many vector processing applications, benchmarking suggests that predicates and overlay computations using S2 are as fast as or faster than those based on 2D projected coordinates. It is planned that these bindings become the default when coordinates are ellipsoidal. Collectively, we see a bright future for S2 in the R language and the greater free and open-source geospatial community.


Whereas many vector processing algorithms require coordinates to be in projected coordinates, processing algorithms are often needed, or simply more convenient, in a global context. Several open source projects currently compute for instance areas from ellipsoidal coordinates by simply assuming they are Cartesian, resulting in meaningless ("squared degree") quantities, without warning. Google's open source S2 Geometry library provides data structures and algorithms for manipulating vector geometry on the sphere; however, its use in open-source GIS software is limited. In addition to most simple feature access operators, S2 Geometry allows for "semi-open" polygons, which uniquely assigns points on boundaries of two touching polygons to a single polygon. This is a welcome addition to DE-9IM for the common case where sets of polygons represent a coverage. In 2020 we created a set of bindings for S2 Geometry in R to add sphere-native capabilities to the sf package, whose functions were previously powered by GEOS for both projected and spherical coordinates. Our bindings reconciled a number of differences between S2 Geometry's C++ API and GEOS' C API that were needed for a seamless transition for users of sf. In addition to eliminating the need for projected coordinates for many vector processing applications, benchmarking suggests that predicates and overlay computations using S2 are as fast as or faster than those based on 2D projected coordinates. It is planned that these bindings become the default when coordinates are ellipsoidal. Collectively, we see a bright future for S2 in the R language and the greater free and open-source geospatial community.


Authors and Affiliations

Dunnington, Dewey (1); Pebezma, Edzer (2)

(1) Bedford Institute of Oceanography, Dartmouth, Nova Scotia, Canada
(2) Institute for Geomatics, University of Münster, Münster, Germany

Track

Software

Topic

Software/Project development

Level

3 - Medium. Advanced knowledge is recommended.

Language of the Presentation

English

Dewey Dunnington (Ph.D., P.Geo.) is an environmental researcher, programmer, and educator based in Halifax, Nova Scotia. Dewey’s research investigates the mechanisms that control metal cycling in lakes alongside geospatial applications to environmental research. He is currently a Physical Scientist at Fisheries and Oceans Canada.

This speaker also appears in: