R中的GeoJson数据

R中的GeoJson数据,r,geojson,R,Geojson,我想处理以下格式的GeoJson数据 { "id": 1, "geometry": { "type": "Point", "coordinates": [ -3.706, 40.3], "properties": {"appuserid": "5b46-7d3c-48a6-9c08-cc894", "eventtype": "location", "devicedate": "2016-06-08

我想处理以下格式的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": ""
      }}}
问题是我想使用一个“Where”子句来定义“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.
库(jsonlite);

con
jqr
是一个选项,jq的R客户端


sqldf在数据帧上工作,要求您提供有效的SQL字符串作为第一个参数。d是数据帧吗?$不是SQL运算符。建议你复习和复习。谢谢你的回复。但它不适用于数据帧。我建议您尝试使用
dplyr
解析数据帧
    x <- '{
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": {
                    "population": 200
                },
                "geometry": {
                    "type": "Point",
                    "coordinates": [
                        10.724029,
                        59.926807
                    ],
                   "properties": {
                      "appuserid": "5b46-7d3c-48a6-9c08-cc894"
                   }
                }
            },
            {
                "type": "Feature",
                "properties": {
                    "population": 600
                },
                "geometry": {
                    "type": "Point",
                    "coordinates": [
                        10.715789,
                        59.904778
                    ],
                   "properties": {
                      "appuserid": "c7e866a7-e32d-4dc2-adfd-c2ca065b25ce"
                    }
                }
            }
        ]
    }'

    library(jqr)
    jq(x, '.features[] | select(.geometry.properties.appuserid == "5b46-7d3c-48a6-9c08-cc894")')
    {
        "type": "Feature",
        "properties": {
            "population": 200
        },
        "geometry": {
            "type": "Point",
            "coordinates": [
                10.724029,
                59.926807
            ],
            "properties": {
                "appuserid": "5b46-7d3c-48a6-9c08-cc894"
            }
        }
    }