How to plot a tilted map?
If, instead of manipulating an image, you would like to directly generate a rotated geographical projection, you can use the techniques outlined by @Jose in his answer to this question (Rotate Geographic map).
In your case, for instance, you could try:
GeoGraphics[
GeoRange -> {{-46, -40}, {165.5, 173}}, GeoRangePadding -> Full,
GeoProjection -> {"ObliqueMercator", "Centering" -> {{-43, 170}, 40}},
GeoBackground -> "ReliefMap",
GeoGridLines -> Automatic
]
If you want it horizontal,
ImageTake[ImageRotate[p1, -0.8], {250, 350}, {50, 300}]
Or you can rotate it back to its original angle if desired.
p1 = GeoGraphics[GeoRange -> CountryData["NewZealand"], GeoBackground -> "ReliefMap"]
gr = AbsoluteOptions[p1, GeoRange][[1]]
GeoRange -> {{-47.2892, -33.7793}, {165.82, 179.157}}
pr = AbsoluteOptions[p1, PlotRange][[1]]
PlotRange -> {{165.82, 179.157}, {-53.8038, -35.9255}}
Note the differences between gr
and pr
.
p2 = Graphics[
{White, Polygon[{{174, -39}, {176, -43}, {168, -47}, {166, -43}, {174, -39}}]},
Background -> Black, PlotRange -> Reverse@gr[[2]], ImageSize -> ImageDimensions@p1];
p3 = Show[p1, p2]; (* Only for illustration *)
{p2, p3}
ImageCrop @ ImageAdd[ImageMultiply[p1, p2], ColorNegate @ p2]