Come si scrive un array json da R che ha una sequenza di lat e long?Come si scrive un array json da R che ha una sequenza di lat e long?
vorrei scrivere:
[[[1,2],[3,4],[5,6]]]
il meglio che posso fare è:
toJSON(matrix(1:6, ncol = 2, byrow = T))
#"[ [ 1, 2 ],\n[ 3, 4 ],\n[ 5, 6 ] ]"
Come posso avvolgere la cosa in un altro array (il tipo JSON)? Questo è importante per me così posso scrivere file in un formato geojson come LineString.
Puoi mostrare il formato finale con 'LineString'? – m0nhawk
Nel caso in cui non si fosse a conoscenza, il pacchetto 'rgdal' può scrivere geojson. Ad esempio: 'library (rgdal); biblioteca (sp); xy <- data.frame (id = seq_len (100), x = runif (100, 145, 150), y = runif (100, -38, -35)); coordinate (xy) <- ~ x + y; writeOGR (xy, 'xy.js', layer = '', driver = "GeoJSON") '. – jbaums