在迭代R中使用st_read导入大的geojson [英] Using st_read to import large geojson in iterations R

查看:105
本文介绍了在迭代R中使用st_read导入大的geojson的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用R中的st_read将非常大的geojson导入到简单的特征对象中,但是从geojson转换为sf时,硬件需求似乎很大.例如,导入Microsoft数据以建立俄亥俄州的足迹( https://github.com/Microsoft/USBuildingFootprints)(1.2 GB的geojson)在转换时会占用32 GB以上的RAM.他们是一种在函数中迭代geojson行的方法,这样我就可以导入整个文件的一部分而不会耗尽所有RAM,这类似于在read.csv中跳过行吗?

I want to import a very large geojson into a simple features object using st_read in R, however the hardware demands seem to be large when converting from geojson to sf. for example, importing the microsoft data for building footprints for Ohio (https://github.com/Microsoft/USBuildingFootprints) which is a 1.2 GB geojson eats up over 32 GB of RAM when converting. Is their a method for iterating through rows of a geojson in a function so I can import parts of the whole file without eating up all that RAM, similar to skip rows in read.csv?

推荐答案

在具有16GB RAM的Mac上使用library(geojsonsf)似乎可以正常工作

Using library(geojsonsf) seems to work without issue on my Mac with 16gb RAM

library(geojsonsf)
library(sf)

sf <- geojsonsf::geojson_sf("~/Downloads/Ohio.geojson")

sf
# Simple feature collection with 5449419 features and 0 fields
# geometry type:  POLYGON
# dimension:      XY
# bbox:           xmin: -84.82027 ymin: 38.40334 xmax: -80.51887 ymax: 41.97041
# epsg (SRID):    4326
# proj4string:    +proj=longlat +datum=WGS84 +no_defs
# First 10 features:
#   geometry
# 1  POLYGON ((-84.81222 39.9087...
# 2  POLYGON ((-84.80084 39.8882...
# 3  POLYGON ((-84.78565 39.8811...
# 4  POLYGON ((-84.7373 39.9014,...
# 5  POLYGON ((-84.73916 39.8980...
# 6  POLYGON ((-84.80422 39.8646...
# 7  POLYGON ((-84.80025 39.8592...
# 8  POLYGON ((-84.79336 39.8593...
# 9  POLYGON ((-84.79268 39.8604...
# 10 POLYGON ((-84.80194 39.8639...

这篇关于在迭代R中使用st_read导入大的geojson的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆