Database

[{_id:1,location:"Station One",datetime:ISODate("2019-02-02T12:54:57.937Z"),sensorType:"temperature",value:-1.8,__v:0},{_id:2,location:"Station two",datetime:ISODate("2019-02-02T09:49:39.200Z"),sensorType:"temperature",value:-2,__v:0},{_id:3,location:"Station One",datetime:ISODate("2019-02-02T09:49:39.200Z"),sensorType:"ph",value:-2,__v:0},{_id:4,location:"Station two",datetime:ISODate("2019-02-02T09:49:39.200Z"),sensorType:"ph",value:-2,__v:0},]

Query

db.collection.aggregate([{$sort:{value:1}},{$group:{_id:{sensorType:"$sensorType",location:"$location"},min:{$first:"$$ROOT"},max:{$last:"$$ROOT"}}},{$sort:{"_id.location":1,"_id.sensorType":1,}},{$project:{_id:1,max:{value:"$max.value",month:{$month:"$max.datetime"},year:{$year:"$max.datetime"},day:{$dayOfMonth:"$max.datetime"}},min:{value:"$min.value",month:{$month:"$min.datetime"},year:{$year:"$min.datetime"},day:{$dayOfMonth:"$min.datetime"}}}},{$group:{_id:"$_id.location",sensorData:{$push:{k:"$_id.sensorType",v:{max:"$max",min:"$min"}}}}},{"$replaceRoot":{"newRoot":{"$arrayToObject":[[{k:"$_id",v:{"$arrayToObject":"$sensorData"}}]]}}}])

Result