Our teachers, the authors of the Shulchan Aruch, wrote in section 2 (Shulchan Aruch Yoreh Deah 363:2): One may not transport a deceased person from a city that has a cemetery to another city, unless it is from outside the Land to the Land, or if they are transporting him to the place of his fathers' graves. And if he commanded to transport him from place to place, or if he commanded to bury him in his house and not in the cemetery – we listen to him. And it is permitted to place lime upon him in order to decompose the flesh quickly, and to transport him to the place which he commanded. Thus far their wording. And some have written the reason that "one may not transport etc." is because of the honor of the deceased who are buried here (Shach, subsection 4). And they raised a difficulty regarding this: for if so, why is it permitted when he commanded? Rather, the reason is so that he will not decompose on the way and be disgraced (the Gaon Rabbi Akiva Eiger in the name of Z.Y.). And I wonder: for perforce when he commanded to bury him in his house, the reason of decomposition is not relevant, but rather because of the honor of the deceased, and nevertheless when he commanded – it is permitted. And if so, here too when he commanded to bury him in another place, it is specifically when we act of our own accord that it is a disgrace to the deceased who are here, which is not the case when we act according to a command. And that which he commanded so is not a disgrace to the deceased who are here, for presumably he has some reason for this, and every person may do as he wishes regarding himself. And on the contrary, in my humble opinion, if there is a concern that he will decompose on the way – even when he commanded we do not listen to him. And more than this I found in the name of Sefer Chasidim (siman 720 and brought in the Ba'er Heitev) that one commanded his son to transport him to the place of his fathers, and the time was hot and they feared decomposition, and they ruled that he does not need to fulfill his command, see there. Rather, the reason is only because of the disgrace of the deceased. (And it is possible that therefore they wrote that it is permitted to place lime upon him etc., in order to fulfill his command. And certainly when there is a solution – one should fulfill the command. But when there is no solution – one should not fulfill it.)
כתבו רבותינו בעלי השולחן ערוך בסעיף ב (שולחן ערוך יורה דעה שסג, ב): אין מוליכין מת מעיר שיש בה קברות לעיר אחרת, אלא אם כן מחוץ לארץ לארץ, או שמוליכין אותו למקום קברות אבותיו. ואם צוה להוליכו ממקום למקום, או שצוה לקוברו בביתו ולא בבית הקברות – שומעין לו. ומותר ליתן סיד עליו כדי לעכל הבשר מהר, ולהוליכו למקום אשר צוה. עד כאן לשונם. ויש שכתבו הטעם ד"אין מוליכין וכו'" משום כבוד המתים הקבורים כאן (ש"ך סעיף קטן ד). והקשו על זה: דאם כן בצוה למה מותר? אלא הטעם כדי שלא יתקלקל בדרך ויתבזה (הגאון רבי עקיבא איגר בשם ז"י). ואני תמה: דהא בעל כרחך כשצוה לקוברו בביתו לא שייך טעם שיתקלקל, אלא מפני כבוד המתים, ועם כל זה כשצוה – מותר. ואם כן הכא נמי כשצוה לקוברו במקום אחר, דדווקא כשאנו עושין מעצמינו הוה בזיון להמתים שבכאן, מה שאין כן כשעושין על פי צוואה. ומה שצוה כן אין זה בזיון להמתים שבכאן, דמסתמא יש לו איזה טעם בזה, וכל אדם על עצמו יכול לעשות כרצונו. ואדרבא לעניות דעתי אם יש חשש שיתקלקל בדרך – אפילו כשצוה אין שומעין לו. ויותר מזה מצאתי בשם ספר חסידים (סימן תש"כ והובא בבאר היטב) שאחד צוה לבנו להוליכו למקום אבותיו, והיה הזמן חם וחששו לקלקול, ופסקו שאינו צריך לקיים צוואתו, עיין שם. אלא הטעם הוא רק משום בזיון המתים. (ואפשר דלכן כתבו דמותר ליתן עליו סיד וכו', בכדי לקיים צוואתו. ובוודאי כשיש עצה – יש לקיים הצוואה. אבל באין עצה – אין לקיים.)