14
$\begingroup$

I want the map to be rotated by -45 Degree. I want to coast to be horizontal (perfect -45 degree). I already have:

loc = GeoPosition[{52.57243, 5.51780}];
loc1 = GeoPosition[{52.57718, 5.52193}];
loc2 = GeoPosition[{52.57449, 5.52636}];
loc3 = GeoPosition[{52.56495, 5.51071}];
loc4 = GeoPosition[{52.56765, 5.50631}];
GeoGraphics[{Red, Thick,GeoPath[{{loc1, loc2}, {loc2, loc3}, {loc3, loc4}, {loc4, loc1}}], GeoStyling["StreetMap"]}, GeoZoomLevel -> 14,GeoScaleBar -> Placed["meters", {Center, Top}], GeoCenter -> loc,GeoRange -> Quantity[2, "Kilometers"]]

I already tried the rotate function which gave unsatisfying results. The code (without rotation) gives the following result:

Result without rotation

But I want it to look like this (inluding a -45 degree rotation and where coordinates are still displayed correctly):

Map with a -45 degree rotation

I also tried the following which is an edited copy from Mathematica documentation center:

upsidedown = (ImageTransformation[#, RotationTransform[Pi/4], DataRange -> {Automatic, {-1, 1}}] &);
downunder = GeoDisk[loc, Quantity[2, "Kilometers"]];
bestemmingsgebied = GeoPath[{{loc1, loc2}, {loc2, loc3}, {loc3, loc4}, {loc4, loc1}}];

GeoGraphics[{GeoStyling["StreetMap", GeoStylingImageFunction -> upsidedown], downunder, bestemmingsgebied}, GeoBackground -> GeoStyling["StreetMapNoLabels"], GeoCenter -> loc, GeoScaleBar -> Placed["meters", {Center, Top}]]

This results in the following picture:

it didn't rotate

Unfortunately the box didn't rotate, so is there a way to do this?

Oh btw I'm using version 10.3.

Thanks in advance!

$\endgroup$
  • 1
    $\begingroup$ Dirty work around is to add GeoRangePadding, move GeoScaleBar inside, Rotate result, Rasterize and ImageTake appropriate part. $\endgroup$ – Kuba Jun 6 '16 at 13:28
  • 3
    $\begingroup$ Your original map is in the "Mercator" projection, so something you can do to rotate it is to use the "ObliqueMercator" projection. For example, try to add GeoProjection -> {"ObliqueMercator", "Centering" -> {loc, 45}} to your GeoGraphics input. $\endgroup$ – jose Jun 7 '16 at 18:43
  • 1
    $\begingroup$ @jose I think it's worth an answer, don't you agree? $\endgroup$ – Kuba Jun 8 '16 at 12:04
  • $\begingroup$ @jose Thanks it works like a charm, Kuba thank you aswell for your reaction! $\endgroup$ – Dennis Jun 9 '16 at 5:26
  • $\begingroup$ @jose Yes please enter your comment as an answer. I had been toying with this question for quite some time, to no avail. I'd love to have your suggestion preserved as a proper answer! $\endgroup$ – MarcoB Jun 9 '16 at 18:01
6
$\begingroup$

A possible way to rotate a map is to use the freedom provided by an oblique projection. Obliqueness adds the three degrees of freedom of a general 3D rotation, namely the {lat, lon} coordinates of the new pole and a rotation around that point.

In the future, the WL projection engine will support obliqueness for all projections, but currently some of the projections specifically have the freedom of obliqueness. In this case your original map uses the "Mercator" projection, because it is a low scale map, and the WL has its oblique version, called "ObliqueMercator", both for spherical and for ellipsoidal models. Note that there is also a "TransverseMercator", very important in the UTM family of projections, also available both for spherical and ellipsoidal models.

The idea is to use the projection {"ObliqueMercator", "Centering" -> {p, alpha}}, where p is a point on the new equator and alpha is a rotation in degrees around that point p, positive clockwise as standard with azimuths in geography. Using your definitions, and adding geo grid lines for orientation:

GeoGraphics[{Red, Thick, GeoPath[{loc1, loc2, loc3, loc4, loc1}]}, GeoScaleBar -> Placed["Metric", {Center, Top}], GeoCenter -> loc, GeoProjection -> {"ObliqueMercator", "Centering" -> {loc, 45}}, GeoGridLines -> Automatic]

enter image description here

$\endgroup$
  • $\begingroup$ “In the future, the WL projection engine will support obliqueness for all projections”?? $\endgroup$ – yode Jun 10 '16 at 5:41
  • $\begingroup$ @yode, jose is saying that oblique versions of the built-in map projections will eventually be implemented, which will allow arbitrarily oriented maps such as the one in this post, among other things. $\endgroup$ – J. M. will be back soon Jun 10 '16 at 7:56
  • 1
    $\begingroup$ Thanks for your response. @J.M. I'm just surprise Mr. jose know the future. :) $\endgroup$ – yode Jun 10 '16 at 7:59
  • 1
    $\begingroup$ Ha, ha. I just updated my profile data to explain where I got my crystal ball... $\endgroup$ – jose Jun 10 '16 at 16:06
  • $\begingroup$ Jose, thanks for posting the answer and its explanation. (+1) $\endgroup$ – MarcoB Jun 13 '16 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.