A service for updating your home location already exists.
https://www.home-assistant.io/integrations/homeassistant#service-homeassistantset_location
It was added precisely for this application, i.e. home assistant on boats or RVs.
e.g.
trigger:
- platform: state
entity_id: sensor.gps_latitude
not_to:
- unknown
- unavailable
- platform: state
entity_id: sensor.gps_longitude
not_to:
- unknown
- unavailable
action:
- service: homeassistant.set_location
data:
latitude: "{{ states('sensor.gps_latitude') }}"
longitude: "{{ states('sensor.gps_longitude') }}"
mode: single