TransWikia.com

Having trouble getting map data for the Maldive Islands

Mathematica Asked on November 29, 2020

enter image description here
I change the island and GeoRange from the example, but it shows the error, can anyone help me with that?

Follow link as the original example(The first and second pictures) :
https://risu.io/SOmU

map = GeoGraphics[Entity["Country", "MaldiveIslands"]["Polygon"],
  GeoRange -> {{0, 8}, {72, 74}}, GeoBackground -> None, ImageSize -> 2048];
image = Binarize[Image[ImageData[Image[map]][[All, All, 4]]]];
labeledArray = MorphologicalComponents[image];

2 Answers

The cause of the error message may be that Entity["Country", "MaldiveIslands"]["Polygon"] evaluates to Missing["UnknownEntity", {"Country", "MaldiveIslands"}]

The following code, which is similar to yours, evaluates without an error message. It uses "Maldives" instead of "MaldiveIslands" and an image size of 160 instead of 2048.

map = GeoGraphics[{EdgeForm[Gray],
    Entity["Country", "Maldives"]["Polygon"]},
   GeoBackground -> None,
   GeoRange -> {{0, 8}, {72, 74}},
   ImageSize -> 160];
image = Binarize[Image[ImageData[Image[map]][[All, All, 4]]]]; 
labeledArray = MorphologicalComponents[image];
Dimensions@labeledArray

(*  {1413, 352}  *)

Answered by LouisB on November 29, 2020

Another way.

map =
 GeoGraphics[{GeoStyling[None], Polygon @ CountryData["Maldives"]},
  GeoRange -> "Country",
  GeoBackground -> None,
  ImageSize -> 400]
image = Rasterize[map, "Image", RasterSize -> 400, ImageSize -> 400];
labeledArray = MorphologicalComponents[image];
Colorize[labeledArray, ColorRules -> {0 -> Red}]

image

Answered by m_goldberg on November 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP