Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Created September 25, 2023 22:54
Show Gist options
  • Save mdsumner/21c5e74f8565487e3304dedf596a10c4 to your computer and use it in GitHub Desktop.
Save mdsumner/21c5e74f8565487e3304dedf596a10c4 to your computer and use it in GitHub Desktop.
#this file
#system.file("extdata/point.shp", package = "vapour")


## all good 
f <- "/vsicurl/https://github.com/hypertidy/vapour/raw/main/inst/extdata/point.shp"
sf::read_sf(f)
## 10 points

## SEGFAULT
#sf::read_sf(f, use_stream = T)
 *** caught segfault ***
address 0x8, cause 'memory not mapped'

Traceback:
 1: CPL_read_gdal_stream(stream, dsn, layer, query, as.character(options),     quiet, drivers, wkt_filter, dsn_exists, dsn_isdb, fid_column_name,     getOption("width"))
 2: st_read.character(..., quiet = quiet, stringsAsFactors = stringsAsFactors,     as_tibble = as_tibble)
 3: st_read(..., quiet = quiet, stringsAsFactors = stringsAsFactors,     as_tibble = as_tibble)
 4: sf::read_sf(f, use_stream = T)

@mdsumner
Copy link
Author

mdsumner commented Sep 25, 2023

and, in Python

from osgeo import ogr
ogr.UseExceptions()
ds = ogr.Open("/vsicurl/https://github.com/hypertidy/vapour/raw/main/inst/extdata/point.shp")
l = ds.GetLayer(0)
arr = l.GetArrowStreamAsPyArrow()
arr.GetNextRecordBatch()


<pyarrow.lib.StructArray object at 0x7f088f86f6a0>
-- is_valid: all not null
-- child 0 type: int64
  [
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9
  ]
-- child 1 type: int32
  [
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10
  ]
-- child 2 type: binary
  [
    01010000000000C09EB2F2E33F000040B88653D83F,
    0101000000000000471CA8C23F000000B55D4FD93F,
    010100000000008032D1D5C73F0000C06A987AD83F,
    0101000000000000CBCF73E73F0000C01B2134D83F,
    01010000000000600818ADEC3F0000E09AEC77E23F,
    01010000000000C0403CBBD03F0000800E3025D53F,
    01010000000000803C350DE03F000000F06E81A73F,
    0101000000000040768DA1EF3F0000807095CBE03F,
    01010000000000806A0310D23F000000586AB2C83F,
    0101000000000000D005F3A93F000040353CF2DF3F
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment