1
$\begingroup$

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];
$\endgroup$
4
  • 1
    $\begingroup$ Post the code instead of picture. $\endgroup$
    – cvgmt
    Commented Nov 9, 2020 at 5:17
  • $\begingroup$ GeoGraphics[{EdgeForm[Gray],Entity["Island", "MaldiveIslands"]["Polygon"]},GeoRange->{{0,8}, {72,74}},GeoBackground->"Satellite",GeoZoomLevel->7] $\endgroup$
    – JOHN
    Commented Nov 9, 2020 at 5:26
  • $\begingroup$ map=GeoGraphics[Entity["Country", "MaldiveIslands"]["Polygon"],GeoRange->{{0,8}, {72,74}},GeoBackground->None,ImageSize->2048]; image=Binarize[Image[ImageData[Image[map]][[All,All,4]]]];[IndentingNewLine]labeledArray=MorphologicalComponents[image]; $\endgroup$
    – JOHN
    Commented Nov 9, 2020 at 5:27
  • $\begingroup$ Edit the original problem and add the code :) $\endgroup$
    – cvgmt
    Commented Nov 9, 2020 at 5:31

2 Answers 2

1
$\begingroup$

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}  *)
$\endgroup$
1
$\begingroup$

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

$\endgroup$

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.