Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to plot polygons for multiple countries, say "UnitedStates" and "Canada". US data is generated thus:

coordsUS = CountryData["UnitedStates", "Coordinates"]

and Canadian data thus:

coordsCanada = CountryData["Canada", "Coordinates"]

I want to pass the combination of these two lists into the routines on this page. I cannot figure out how to combine these two lists into a single list of the same structure. The structure is:

{{{a,b},{c,d},{e,f}}}

I know how to combine lists of the following form:

{{a,b},{c,d},{e,f}} 

but the extra depth is confounding me. I try putting the latter into a list thus:

l = {{a,b},{c,d},{e,f}} 
z = {l}

but that does not work. AppendTo does not work either.

Help is appreciated. Thanks!

-Tony

share|improve this question

2 Answers 2

If your aim is just to plot Canada and the United States, "SchematicPolygon" may be what you want. You could use:

canus = {usa, 
    canada} = {CountryData["UnitedStates", "SchematicPolygon"], 
    CountryData["Canada", "SchematicPolygon"]};
Graphics[canus]

enter image description here

If you want to get the polygon coordinates, and display both (you can use Join):

canusp = Join @@ (canus /. Polygon[x__] :> x);
Graphics[{FaceForm[None], EdgeForm[Red], Polygon[canusp]}]

You can choose whatever styling suits your needs.

Apologies if I have misunderstood your question. enter image description here

share|improve this answer
    
@ubqdqn Good answer, but I hope that this isn't our future :) –  eldo Jun 28 at 19:33

You can use the Flatten[ ] function (first level) on both lists, and combine those results. More specifically,

coordsUS = Flatten[CountryData["UnitedStates", "Coordinates"], 1]

and

coordsCanada = Flatten[CountryData["Canada", "Coordinates"], 1]

are in the form that you are familiar with combining. For reference see Flatten.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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