I'm currently employed as an engineer. I've been at my current job for about 4 years. I'm quite happy with the work, and with my coworkers, and with the working environment as a whole; I honestly have no complaints with my job. And I'm pretty sure they have no complaints with me.
BUT: I'm starting to feel disenchanted and fatigued with the sub-industry I'm in. And looking candidly at myself, I don't think I'd be happy staying in that sub-industry long-term; I'd much rather move to a particular different field.
Now, in a position of some importance to the company, as the lead engineer on one of the products. My team is small, and there's nobody currently on it who could reasonably be expected to take my place without a long and unproductive learning process... and the company doesn't plan to hire anybody else for the team in the foreseeable future. (It's not just a matter of skills: there's a lot of knowledge about my product that someone would need to absorb before taking over, during which time the product could stagnate and lose market share.)
Would it be appropriate/safe/a good idea to give my company a heads-up that I plan to up and quit at some point in the not-so-distant future, to give them lots of lead time to hire or assign or groom someone to replace me?
Some other potentially useful information: I'm quite hireable -- if my employer decided to fire me tomorrow, I wouldn't have any trouble finding a new position, other than the normal annoyance of applying and interviewing and relocating and whatnot. And my managers are friendly, and not retributive... I can't see them firing me early as punishment for not showing enough company loyalty. The field I'm looking to move to has plenty of openings, but I'd rather take as much time as possible to find a position that I'd actually be happy in.
Edit: Some have indicated that this question is a duplicate of "How can I prepare for getting hit by a bus?". Although there are some similarities, the core of the question is about the wisdom of giving advanced notice of departure, and peripherally, what one can do to prepare themselves and their employer for a known eventual departure. "Getting hit by a bus" is an intrinsically random event-- with perhaps different concerns as far as preparation is concerned.