If you plan to use any segment of the GPL'd code of OpenCPN, you need to keep the GPL license in all you code. There are variants (LGPL for linking libraries, AGPL, etc) that have slightly different limits.
Other open source (but not free software) licenses, such as BSD allow privatization/closing.
You must be aware that one of the purposes of the GPL and related licenses is precisely to impede the privatization or closing of software developed as free software. Otherwise, software developed by the authors as an offering to the community would be exploited for profit by unrelated people.
A different issue is if you communicate, say via pipes, sockets, files, ports
, messages, shared memory, etc, with the program. In that case your code need not be GPL.
To date, no court challenge to the GPL have been successful, and all violators have agreed to make the source available. Recent cases involve router makers, for example.