2
$\begingroup$

I have a regional map in a shapefile with datanames and similar, but I can´t use it with data and making a choropleth map. I can´t use the names of each region inside the shapefile. I don´t know how to assign data to each region.

I can only import the region data to a graph.

I can´t assign data to each region, I can´t print the name of each region. Question 1.- How to assign data to each of the 51 regions? Question 2.- How to obtain a choropleth map?

Directory[]
SetDirectory["d:\Users\..."]
estradamap = Import["estrada.zip"]

enter image description here

The shapefile (and dbf and shx) is at https://we.tl/t-7gtTLQPjfA

Question 3.-How to extract the data at .dbf file to a Table[] ?

$\endgroup$
  • $\begingroup$ does Import["estrada.zip", "Data"] give what you need? $\endgroup$ – kglr Nov 14 '18 at 23:45
3
$\begingroup$
dt = Import["estrada.zip", "Data"];
polygons = "Geometry" /. dt[[1]];
labels = "PARROQUIA" /. ("LabeledData" /. dt[[1]]);
values = "SUPERFICIE" /. ("LabeledData" /. dt[[1]]);
Graphics[{{Hue[#], Tooltip[#2, Column[{#3, "SUPERFICIE : " <> ToString@#4}]]} & @@@ 
   Transpose[{Rescale@values, polygons, labels, values}]}]

enter image description here

$\endgroup$
3
$\begingroup$
estradamap = Import["/Users/roberthanlon/Downloads/estrada.zip"];

data = Import["/Users/roberthanlon/Downloads/Estrada.zip", "Data"];

Get names of parishes

names = Cases[data, HoldPattern[Rule["PARROQUIA", names_List]] :> names, 
    Infinity][[1]];

Get surface areas

areas = Cases[data, HoldPattern[Rule["SUPERFICIE", areas_List]] :> areas, 
    Infinity][[1]];

{minArea, maxArea} = MinMax[areas]

(* {100.076, 2150.27} *)

cf = "TemperatureMap"; (* color function *)

Names and areas are placed in Tooltip

n = 1; (* index *)
Legended[
 estradaChoroplethMap = 
  estradamap /. 
   Polygon[pts_] :> {ColorData[cf][Rescale[areas[[n]], {minArea, maxArea}]], ,
      Tooltip[Polygon[pts], names[[n]] <> "\n" <> ToString[areas[[n++]]]]}, 
 BarLegend[{cf, {minArea, maxArea}}]]

enter image description here

EDIT: For a table of the data

{names, (NumberForm[#, {7, 3}, NumberPadding -> {" ", "0"}] & /@ areas)} // 
   Transpose // 
  Prepend[#, (Style[#, 14, Bold] & /@ {"PARROQUIA", "SUPERFICIE"})] & // 
 Grid[#, Frame -> All, Alignment -> Left] &
$\endgroup$

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.