If a wizard casts the spell Dimension Door as part of the casting of the spell Contingency, when is the moment of the choice of the place to reach? The choice is part of the casting or of the effect? If it was part of the casting the wizard could still state the relative position.
You must pick targets at the time of casting
However, you're not out of luck. From Dimension Door,
You arrive at exactly the spot desired. It can be a place you can see, one you can visualize, or one you can describe by stating distance and direction, such as 200 feet straight downward or upward to the northwest at a 45-degree angle, 300 feet.
Unless you plan on being within 500 feet of your chosen destination when Contingency activates, you should use the alternative option and specify a direction and distance.
This can lead to some humorous situations where your intention was to teleport 500 ft. up when you get injured in a Dungeon, but you've just returned to town and bumped into a drunkard who gave you a sucker punch, causing you to be teleported 500 ft. above town. Be careful what you pick for your contingency trigger and effect because it will be activated...
The contingent spell takes effect immediately after the circumstance is met for the first time, whether or not you want it to, and then contingency ends.