我想處理具有下述格式的GeoJson數據;R中的GeoJson數據
{ "id": 1,
"geometry":
{ "type": "Point",
"coordinates": [
-3.706,
40.3],
"properties": {"appuserid": "5b46-7d3c-48a6-9c08-cc894",
"eventtype": "location",
"devicedate": "2016-06-08T07:25:21",
"date": "2016-06-08T07:25:06.507",
"location": {
"building": "2",
"floor": "0",
"elevation": ""
}}}
的問題是我想用一個「去哪兒」條款爲「appuserid」,並選擇要處理選定的記錄。我不知道該怎麼做?我已經在數據框中保存了Mongodb的數據。
現在我正在嘗試做如下;
library(sqldf)
sqldf("SELECT * FROM d WHERE d$properties$appuserid = '0000-0000-0000-0000'")
但它給出了一個錯誤。
Error: Only lists of raw vectors are currently supported
代碼在下面;
library(jsonlite);
con <- mongo(collection = "geodata", db = "MongoDb", url = "mongodb://192.168.26.18:27017", verbose = FALSE, options = ssl_options());
d <- con$find();
library(jqr)
jq(d, '.features[] | select(d$properties$appuserid == "5b46-7d3c-48a6-9c08-cc894")')
Error : Error in jq.default(d, ".features[] | select(d$properties$appuserid == \"5b46-7d3c-48a6-9c08-cc894\")") :
jq method not implemented for data.frame.
上的數據幀sqldf工作,並要求您提供一個有效的SQL字符串作爲第一個參數。是數據框嗎? $不是一個SQL運算符。建議您查看[問]和[mcve]。 –