4
$\begingroup$

I would like to construct Turkey's map using Geocoordinate of each city. This link has all coordinate of of cities but I don't know how to extract the data from website. I did manually two cities and it seems it is working.

hatay={{36.0616, 37.0235}, {36.2547, 37.0087}, {36.3472, 36.9553}, {36.4426,
   36.9533}, {36.6261, 36.841}, {36.6685, 36.8368}, {36.6786, 
  36.8185}, {36.6271, 36.7577}, {36.6369, 36.7051}, {36.588, 
  36.636}, {36.5999, 36.562}, {36.5529, 36.497}, {36.5891, 
  36.3978}, {36.6226, 36.3912}, {36.6277, 36.3542}, {36.6078, 
  36.3299}, {36.6662, 36.3302}, {36.6711, 36.3024}, {36.7003, 
  36.2922}, {36.7048, 36.2503}, {36.6184, 36.2166}, {36.5839, 
  36.2321}, {36.4954, 36.2345}, {36.4711, 36.2018}, {36.3975, 
  36.2232}, {36.4006, 36.1915}, {36.3767, 36.1694}, {36.3978, 
  36.0838}, {36.3786, 36.001}, {36.3442, 35.9924}, {36.3172, 
  36.0041}, {36.2979, 35.9917}, {36.3025, 35.9574}, {36.2127, 
  35.9515}, {36.1809, 35.9017}, {36.1831, 35.8356}, {36.1691, 
  35.8154}, {36.1164, 35.8655}, {36.0187, 35.8811}, {36.0229, 
  35.9245}, {36.0085, 35.9403}, {35.9358, 35.9187}, {35.9185, 
  35.9323}, {35.979, 36.019}, {35.8968, 36.1579}, {35.7804, 
  36.2988}, {35.781, 36.3224}, {35.816, 36.3604}, {35.8535, 
  36.369}, {35.8604, 36.3957}, {35.896, 36.4154}, {35.9096, 
  36.4451}, {35.9826, 36.4743}, {36.0368, 36.5337}, {36.1851, 
  36.7243}, {36.1888, 36.7232}, {36.1888, 36.7226}, {36.186, 
  36.7224}, {36.1851, 36.7243}, {36.1488, 36.5907}, {36.1946, 
  36.596}, {36.2157, 36.6593}, {36.1926, 36.7051}, {36.2021, 
  36.7271}, {36.1871, 36.729}, {36.206, 36.7824}, {36.1485, 
  36.8551}, {36.1296, 36.8532}, {36.1407, 36.8621}, {36.0857, 
  36.9051}, {36.0171, 36.9301}, {35.9376, 36.8865}, {35.9449, 
  36.8743}, {35.9457, 36.8643}, {35.9136, 36.8955}, {35.9542, 
  36.9637}, {36.0416, 37.0256}, {36.0616, 37.0235}};
osmaniye={{36.3279, 37.3484}, {36.4889, 37.3689}, {36.5828, 37.4052}, {36.651, 
  37.33}, {36.7286, 37.2761}, {36.5325, 37.1075}, {36.4426, 
  36.9533}, {36.3472, 36.9553}, {36.2547, 37.0087}, {36.0416, 
  37.0256}, {36.0594, 37.1239}, {36.001, 37.1742}, {35.8748, 
  37.1217}, {35.8528, 37.1287}, {35.9043, 37.2083}, {35.8818, 
  37.2416}, {35.8843, 37.3596}, {36.0233, 37.5623}, {36.1504, 
  37.6354}, {36.3024, 37.6512}, {36.2121, 37.5002}, {36.2463, 
  37.3709}, {36.3279, 37.3484}};

GeoGraphics[{EdgeForm[Black], GeoStyling[Red, Opacity[0.7]], 
  Polygon[hatay], GeoStyling[Green, Opacity[0.7]], Polygon[osmaniye]}]

enter image description here

Here is the link for city map of Turkey. Any suggestion.

Edit

After @C.E. suggestion I made this heat map for population of city of Turkey. This is so cool.

population=Log@{2.21648*10^6, 615076., 715693., 536285., 402404., 329888., 
 5.44503*10^6, 2.3644*10^6, 97096., 166143., 1.08084*10^6, 
 1.20482*10^6, 193577., 585252., 80417., 221693., 273354., 341474., \
303184., 264779., 2.9368*10^6, 530417., 186074., 528422., 
 1.01874*10^6,      1.6999*10^6, 377610., 406855., 583671., 231511., 760476., 860620.,      2.00552*10^6, 437393., 170173., 275761., 
 1.57523*10^6, 194775., 433830., 1.50292*10^7, 4.27968*10^6, 
 1.12762*10^6, 244453., 246672., 287654., 372373., 
 1.37672*10^6, 136319., 278749., 356050., 234529., 1.88327*10^6, 
 2.18015*10^6, 572256., 786676., 1.41304*10^6, 809719., 
 1.79393*10^6, 938751., 404544., 292365., 352727., 742341., 527724., \
331041., 990214., 1.31299*10^6,      1.98575*10^6, 324394., 207427., 503236., 621301.,      1.00546*10^6, 602086., 786326., 82498., 364971., 
 1.10689*10^6, 251203., 418650., 596892.};



  minMax = MinMax[population];
vec = {{0, 0, 165}, {40, 50, 220}, {90, 120, 240}, {140, 180, 
    247}, {195, 223, 240}, {230, 227, 230}, {240, 223, 195}, {247, 
    180, 140}, {240, 120, 90}, {220, 50, 40}, {164, 0, 0}};
colAll = Blend[RGBColor @@@ (vec/255), Rescale[#, minMax]] &;
colors = colAll[#] & /@ population;
regions = 
  Entity["Country", "Turkey"][
   EntityProperty["Country", "AdministrativeDivisions"]];
names = StringTrim[#, ", Turkey"] & /@ 
   EntityValue[regions, 
    EntityProperty["AdministrativeDivision", "Name"]];
labelCoordinates = 
  Reverse /@ 
   EntityValue[regions, 
    EntityProperty["AdministrativeDivision", "Coordinates"]];
polygons = 
  EntityValue[regions, 
   EntityProperty["AdministrativeDivision", "Polygon"]];


Legended[Graphics[{EdgeForm[Gray], Riffle[colors, polygons], 
   MapThread[Text, {names, labelCoordinates}]}, ImageSize -> 1000], 
 Placed[BarLegend[{colAll, minMax}, LegendLayout -> "Row", 
   LegendMarkerSize -> {800, 25}], Bottom]]

enter image description here

$\endgroup$
7
$\begingroup$

The data is built into Mathematica, so we can use the entity system to do this.

regions = Entity["Country", "Turkey"][EntityProperty["Country", "AdministrativeDivisions"]];
names = StringTrim[#, ", Turkey"] & /@ EntityValue[regions, EntityProperty["AdministrativeDivision", "Name"]];
labelCoordinates = Reverse /@ EntityValue[regions, EntityProperty["AdministrativeDivision", "Coordinates"]];
polygons = EntityValue[regions, EntityProperty["AdministrativeDivision", "Polygon"]];
colors = ColorData[97, #] & /@ Range[Length[regions]];

Graphics[{
  Riffle[colors, polygons],
  MapThread[Text, {names, labelCoordinates}]
  }, ImageSize -> 1000]

Mathematica graphics

You can also use GeoGraphics to get a different type of visualization of this map. One problem is that there are more regions on this map than there are distinct colors in the color scheme ColorData[97], which means that several regions have the same colors. Some of the regions neighbor each other, unfortunately, which means that we can't tell where the border is.

$\endgroup$
  • $\begingroup$ I used this for border. Graphics[{EdgeForm[Black],......] $\endgroup$ – OkkesDulgerci Jul 15 '18 at 23:26
  • $\begingroup$ @OkkesDulgerci Good, that will do it. $\endgroup$ – C. E. Jul 15 '18 at 23:28
  • $\begingroup$ This is awesome!! I do know that each city has location coordinate, but I did not know Mathematica has coordinate of each city along the border. $\endgroup$ – OkkesDulgerci Jul 15 '18 at 23:28
  • 1
    $\begingroup$ @OkkesDulgerci What we get is a list of latitude and longitude values. You can consider latitude to be the x coordinate and longitude to be the y values. The regions will fit perfectly with each other because the longitudes and latitudes on their shared borders are the same for both regions. One difference between Graphics and GeoGraphics is that GeoGraphics can do different projections (as we know, there is more than one way to plot the spherical surface of the earth in two dimensions.) $\endgroup$ – C. E. Jul 15 '18 at 23:35
  • 1
    $\begingroup$ @OkkesDulgerci You should have everything you need to do that in my answer. Create a list with all the subdivision entities in it and plot them just like I plotted the larger regions. $\endgroup$ – C. E. Jul 15 '18 at 23:55
1
$\begingroup$
TurkeyCityList = CityData[{All, "Turkey"}];

CityData[#, "Coordinates"] & /@ TurkeyCityList
$\endgroup$
  • 1
    $\begingroup$ This does not answer the question. OP is saying that he wants to create this type of map, which means you need to get the boundary for each region, not just a single coordinate. $\endgroup$ – C. E. Jul 15 '18 at 22:49
  • $\begingroup$ How do you know which cities are to be grouped to define a "region"? $\endgroup$ – David G. Stork Jul 15 '18 at 22:55
  • $\begingroup$ See my answer, we can see that what is thought of in Turkey as cities is what Mathematica considers administrative regions. These have well-defined borders. $\endgroup$ – C. E. Jul 15 '18 at 23:14
  • $\begingroup$ But I see no reason that the regions Mathematica assumes are the ones the OP wants. He doesn't state it as such. $\endgroup$ – David G. Stork Jul 15 '18 at 23:15
  • $\begingroup$ I compared them with the map OP provided and the names are the same, the regions are the same. (It can be a bit difficult to tell because the plot reuses colors, and colors of neighboring regions can have the same color. But I randomized the colors and evaluated several times to check.) $\endgroup$ – C. E. Jul 15 '18 at 23:20

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.