TypeError: Cannot set property 'latitude' of undefined

The current msg.payload is a string (actually is a JSON string - see the "{"batV":.. etc...} your picture) so when you attempt to set msg.payload.content you get an error - because a string is not an object.

try...

msg.payload = {}; //set payload up as a new empty {object}
msg.payload.content = {}; //set payload.content up as a new empty {object}
msg.payload.content.whatever = whatever_i_want; //now you can add properties to the object
return msg;

few things...

  1. please always surround code or JSON with triple backticks
    ```
    like this
    ```
  2. is there any reason you set flow context then get it straight back out of context? (Also, note there is a typo in line 5 - to avoid typos, use the copy path button in the debug side-bar (it appears when you hover over a debug value)
  3. your payload already has the lat/lon but in JSON - where is this payload coming from? If it is from MQTT node, you can have the MQTT node turn the JSON into an object (set MQTT In node to auto parse JSON)