3
$\begingroup$

I have a GeoGraphics image with some countries drawn:

(* countries to plot *)
countries = {
  Entity["Country", "UnitedStates"], 
  Entity["Country", "China"],
  Entity["Country", "Japan"],
  Entity["Country", "SouthKorea"],
  Entity["Country", "UnitedKingdom"],
  Entity["Country", "Australia"]
  }

(* colours to use *)
colours  = {Red, Blue, Green, Black, Orange, Brown}

(* draw plot *)
GeoGraphics[
 MapThread[{GeoStyling[#1], 
    EdgeForm[Directive[Opacity[0]], 
    Polygon[#2]} &, {colours, countries}], 
GeoBackground -> White, 
ImageSize -> Large, 
GeoProjection -> "Mercator", 
GeoRangePadding -> None
]

Q: How could I plot these same polygons with custom positioning, rather than with their positioning reflecting their respective geographic locations?

I imagine this would involve plotting them separately and then cleverly combining them. I have tried with Show[], but this of course aligns the plots.

$\endgroup$

1 Answer 1

3
$\begingroup$

With TranslationTransform as an example:

Graphics[{EdgeForm[Black], FaceForm[White], Opacity[0.3]
  , Entity["Country", "UnitedStates"]["Polygon"]
  , EdgeForm[Black], FaceForm[Lighter@Cyan], Opacity[0.3]
  , GeometricTransformation[
   Entity["Country", "UnitedStates"]["Polygon"]
   , TranslationTransform[{20, -10}]]}
 , Frame -> True
 ]

enter image description here

Other transforms are also available.

$\endgroup$
3
  • $\begingroup$ Thanks for this, just by playing around with TranslationTransform[] I'm basically able to get what I want. Do I lose the features and flexibility of GeoGraphics[] with these polygons by doing this method? For example, changing between types of projections (mercator vs equirectangular)? $\endgroup$ Commented Nov 24, 2022 at 11:34
  • $\begingroup$ Please read the documentation under Details on the GeoGraphics page where it talks about the differences and additions to the standard Graphics functionality. I cannot readily think of a way to have different projections with Graphics but there may be a clever workaround. $\endgroup$
    – Syed
    Commented Nov 24, 2022 at 11:45
  • 1
    $\begingroup$ Many thanks for your help regardless, the projections point is a separate problem. $\endgroup$ Commented Nov 24, 2022 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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