Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upstring limitation for very large geojson #64
Comments
|
Indeed - the solution may be to implement FileReadStream rather than, or as well as the buffer - to - StringVector implementation |
|
working prototype sf <- geojsonsf:::rcpp_read_sf_file_stream(normalizePath("~/Downloads/Texas.geojson"), FALSE)
sf
# Simple feature collection with 9891540 features and 0 fields
# geometry type: POLYGON
# dimension: XY
# bbox: xmin: -106.646 ymin: 25.85305 xmax: -93.52176 ymax: 36.50031
# epsg (SRID): 4326
# proj4string: +proj=longlat +datum=WGS84 +no_defs
# First 10 features:
# geometry
# 1 POLYGON ((-95.61533 30.7471...
# 2 POLYGON ((-95.59383 30.7382...
# 3 POLYGON ((-95.56662 30.7327...
# 4 POLYGON ((-95.55648 30.7391...
# 5 POLYGON ((-95.57037 30.7253...
# 6 POLYGON ((-95.57031 30.7267...
# 7 POLYGON ((-95.57383 30.7276...
# 8 POLYGON ((-95.5707 30.72964...
# 9 POLYGON ((-95.57335 30.7297...
# 10 POLYGON ((-95.569 30.72455,... |
|
timings system.time({
sf <- geojsonsf::geojson_sf("~/Downloads/Texas.geojson", buffer_size = 1024) ## default
})
# user system elapsed
# 126.185 16.056 189.778
system.time({
sf <- geojsonsf::geojson_sf("~/Downloads/Texas.geojson", buffer_size = 2048)
})
rm(list=ls());gc()
# user system elapsed
# 91.989 20.256 127.668
system.time({
sf <- geojsonsf::geojson_sf("~/Downloads/Texas.geojson", buffer_size = 65536)
})
rm(list=ls());gc()
# user system elapsed
# 132.908 13.697 191.704
|
sessionInfo
|
|
The |
I am trying to load the Microsoft building footprint data for Texas (https://github.com/Microsoft/USBuildingFootprints) which is 2.1 GB. However, when i run the code:
footprint_data = "(path to folder containing data)./Texas.geojson"
texas_buildings = geojson_sf(footprint_data)
I get the following error
The same code works for smaller files in the Microsoft data, so it seems like the error is due to the size of the file. Any suggestions would be greatly appreciated :-)
TODO
buffer_stringto userapidjson::FileReadStreamdirectlyfopen()for windowschar writeBuffer[65536];?