Giter Site home page Giter Site logo

libgeos's Introduction

libgeos

Lifecycle: experimental

The goal of libgeos is to provide access to the Geometry Engine, Open Source (GEOS) library.

Examples

wkt <- libgeos:::wkt  ## character vector
wkb <- libgeos:::wkb  ## list of raw vectors

## wkt to wkt is single-element vector
libgeos:::geos_test_roundtrip_wkt(wkt[[1]])
#> [1] "MULTIPOLYGON (((-81.4727554321289062 36.2343559265137003, -81.5408401489257955 36.2725067138672017, -81.5619812011719034 36.2735939025878977, -81.6330642700195028 36.3406867980957031, -81.7410736083983949 36.3917846679687997, -81.6982803344726989 36.4717788696288991, -81.7027969360351989 36.5193405151366974, -81.6699981689452983 36.5896492004395029, -81.3452987670898011 36.5728645324707031, -81.3475418090820028 36.5379142761229971, -81.3247756958007955 36.5136795043945028, -81.3133239746094034 36.4806976318359020, -81.2662353515625000 36.4372062683104971, -81.2628402709960938 36.4050407409667969, -81.2406921386719034 36.3794174194336009, -81.2398910522460938 36.3653640747070028, -81.2642440795898011 36.3524131774901988, -81.3289947509766051 36.3635025024413991, -81.3613739013672017 36.3531608581542969, -81.3656921386719034 36.3390502929687997, -81.3541336059570028 36.2997169494628977, -81.3674545288085938 36.2786979675292969, -81.4063873291016051 36.2850532531737997, -81.4123306274414062 36.2672920227050994, -81.4310379028320028 36.2607192993163991, -81.4528884887695028 36.2395858764648011, -81.4727554321289062 36.2343559265137003)))"
## comparison not exact
libgeos:::geos_test_roundtrip_wkt(wkt[[1]]) == wkt[[1]]
#> [1] FALSE


## wkb to wkb is a single-element list
libgeos:::geos_test_roundtrip_wkb(wkb[1])
#> [[1]]
#>  [1] 01 06 00 00 00 01 00 00 00 01 03 00 00 00 01 00 00 00 1b 00 00 00 00 00 00
#> [26] a0 41 5e 54 c0 00 00 00 60 ff 1d 42 40 00 00 00 20 9d 62 54 c0 00 00 00 80
#> [51] e1 22 42 40 00 00 00 80 f7 63 54 c0 00 00 00 20 05 23 42 40 00 00 00 20 84
#> [76] 68 54 c0 00 00 00 a0 9b 2b 42 40 00 00 00 c0 6d 6f 54 c0 00 00 00 00 26
#>  [ reached getOption("max.print") -- omitted 355 entries ]
## comparison exact
all(libgeos:::geos_test_roundtrip_wkb(wkb[1])[[1]] == wkb[[1]])
#> [1] TRUE


libgeos:::geos_capi_version()
#> [1] "1.13.1"
libgeos:::geos_version_impl()
#> [1] "3.8.0-CAPI-1.13.1 "

try(libgeos:::geos_test_throw_error(), silent = TRUE)

# list
libgeos:::geos_wkb_is_parseable(wkb[1])
#> [1] TRUE

## atomic
libgeos:::geos_wkt_is_parseable(wkt[[1]])
#> [1] TRUE

## list to atomic
libgeos:::geos_wkb_to_wkt(wkb[1])
#> [1] "MULTIPOLYGON (((-81.4727554321289062 36.2343559265136719, -81.5408401489257812 36.2725067138671875, -81.5619812011718750 36.2735939025878906, -81.6330642700195312 36.3406867980957031, -81.7410736083984375 36.3917846679687500, -81.6982803344726562 36.4717788696289062, -81.7027969360351562 36.5193405151367188, -81.6699981689453125 36.5896492004394531, -81.3452987670898438 36.5728645324707031, -81.3475418090820312 36.5379142761230469, -81.3247756958007812 36.5136795043945312, -81.3133239746093750 36.4806976318359375, -81.2662353515625000 36.4372062683105469, -81.2628402709960938 36.4050407409667969, -81.2406921386718750 36.3794174194335938, -81.2398910522460938 36.3653640747070312, -81.2642440795898438 36.3524131774902344, -81.3289947509765625 36.3635025024414062, -81.3613739013671875 36.3531608581542969, -81.3656921386718750 36.3390502929687500, -81.3541336059570312 36.2997169494628906, -81.3674545288085938 36.2786979675292969, -81.4063873291015625 36.2850532531738281, -81.4123306274414062 36.2672920227050781, -81.4310379028320312 36.2607192993164062, -81.4528884887695312 36.2395858764648438, -81.4727554321289062 36.2343559265136719)))"

## atomic to list
libgeos:::geos_wkt_to_wkb(wkt[[1]])
#> [[1]]
#>  [1] 01 06 00 00 00 01 00 00 00 01 03 00 00 00 01 00 00 00 1b 00 00 00 00 00 00
#> [26] a0 41 5e 54 c0 04 00 00 60 ff 1d 42 40 01 00 00 20 9d 62 54 c0 02 00 00 80
#> [51] e1 22 42 40 02 00 00 80 f7 63 54 c0 01 00 00 20 05 23 42 40 fe ff ff 1f 84
#> [76] 68 54 c0 00 00 00 a0 9b 2b 42 40 fd ff ff bf 6d 6f 54 c0 07 00 00 00 26
#>  [ reached getOption("max.print") -- omitted 355 entries ]



## example from DD's blog
libgeos:::intersect_wkt(wkt[[1]], wkt[[2]], 1L)
#> [1] "MULTILINESTRING ((-81.3 36.6, -81.3 36.5), (-81.3 36.5, -81.3 36.5), (-81.3 36.5, -81.3 36.5), (-81.3 36.5, -81.3 36.4), (-81.3 36.4, -81.3 36.4), (-81.3 36.4, -81.2 36.4), (-81.2 36.4, -81.2 36.4))"


## new example with wkb
libgeos:::intersect_wkb(wkb[[1]], wkb[[2]])
#>  [1] 01 05 00 00 00 07 00 00 00 01 02 00 00 00 02 00 00 00 00 00 00 60 19 56 54
#> [26] c0 00 00 00 a0 53 49 42 40 00 00 00 20 3e 56 54 c0 00 00 00 60 da 44 42 40
#> [51] 01 02 00 00 00 02 00 00 00 00 00 00 20 3e 56 54 c0 00 00 00 60 da 44 42 40
#> [76] 00 00 00 20 c9 54 54 c0 00 00 00 40 c0 41 42 40 01 02 00 00 00 02 00 00
#>  [ reached getOption("max.print") -- omitted 197 entries ]

Please note that the libgeos project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

libgeos's People

Contributors

mdsumner avatar

Stargazers

Dewey Dunnington avatar

Watchers

James Cloos avatar  avatar

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.