{"action":"reopened","issue":{"url":"https://api.github.com/repos/jeroen/mongolite/issues/122","repository_url":"https://api.github.com/repos/jeroen/mongolite","labels_url":"https://api.github.com/repos/jeroen/mongolite/issues/122/labels{/name}","comments_url":"https://api.github.com/repos/jeroen/mongolite/issues/122/comments","events_url":"https://api.github.com/repos/jeroen/mongolite/issues/122/events","html_url":"https://github.com/jeroen/mongolite/issues/122","id":291239460,"node_id":"MDU6SXNzdWUyOTEyMzk0NjA=","number":122,"title":"Cannot insert data frame including geospatial object","user":{"login":"stPhena","id":27235668,"node_id":"MDQ6VXNlcjI3MjM1NjY4","avatar_url":"https://avatars2.githubusercontent.com/u/27235668?v=4","gravatar_id":"","url":"https://api.github.com/users/stPhena","html_url":"https://github.com/stPhena","followers_url":"https://api.github.com/users/stPhena/followers","following_url":"https://api.github.com/users/stPhena/following{/other_user}","gists_url":"https://api.github.com/users/stPhena/gists{/gist_id}","starred_url":"https://api.github.com/users/stPhena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stPhena/subscriptions","organizations_url":"https://api.github.com/users/stPhena/orgs","repos_url":"https://api.github.com/users/stPhena/repos","events_url":"https://api.github.com/users/stPhena/events{/privacy}","received_events_url":"https://api.github.com/users/stPhena/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-01-24T14:59:43Z","updated_at":"2018-08-13T12:12:20Z","closed_at":null,"author_association":"NONE","body":"I have a dataset of approximately 18 million rows that I am trying to insert into a MongoDB collection. The important part of the dataset looks like this:\r\n\r\n```\r\n# A tibble: 1,000 x 6\r\n      id    lon   lat depth date                coords        \r\n   <int>  <dbl> <dbl> <dbl> <dttm>              <list>        \r\n 1   656 - 25.5  17.9  35.0 1969-11-17 11:00:00 <S3: geopoint>\r\n 2   840  145   -13.3  NA   1982-07-02 10:00:00 <S3: geopoint>\r\n 3   848 - 70.7  40.6  66.0 1980-04-07 03:34:48 <S3: geopoint>\r\n```\r\nI have created the coords column with `geojson::point()`, with the intention of having MongoDB natively treat it as a geospatial object.  Seen from the other side, it looks like this:\r\n```\r\nObservations: 1,000\r\nVariables: 6\r\n$ id              <int> 656, 840, 848, 927, 1012, 1023, 1037, 1041, 1044, 1050, 1051, 1054, 1057,...\r\n$ lon             <dbl> -25.47, 145.45, -70.72, -57.97, -75.77, -67.10, 93.00, -69.30, -58.62, -7...\r\n$ lat             <dbl> 17.8742, -13.3000, 40.6300, 46.7100, 34.4200, 43.8700, 10.0000, 42.1500, ...\r\n$ depth           <dbl> 35, NA, 66, 453, 344, 85, NA, 193, 457, 36, 237, 191, 86, 199, 73, 165, 1...\r\n$ date            <dttm> 1969-11-17 11:00:00, 1982-07-02 10:00:00, 1980-04-07 03:34:48, 1988-02-0...\r\n$ coords          <list> [{\"type\":\"Point\",\"coordinates\":[-25.47, 17.8742]}, {\"type\":\"Point\",\"coor...\r\n```\r\nWhen I try to send data to the Mongo collection, I get this error:\r\n```\r\n> myMongo$insert(upload)\r\nError: No method asJSON S3 class: geojson\r\n```\r\nAmong the `toJSON()` parameters I could not find anything to manage these objects. Is mongolite able to insert data frames with a geospatial feature?\r\nEdit: In other words, can we specify two columns to be treated as (lon, lat) and thus be parsed as such into the JSON?\r\nThanks in advance."}}
{"actor":{"display_login":"stPhena"}}