0

I want to create a cartogram(specifically a tilegram like this) using data from GADM and population figures as the subject variable.

Step 1: Get a json data file from GADM

germany_1 <- read_sf("gadm41_DEU_1.json")

This is what I have:

# germany_1$geometry

Geometry set for 16 features 
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 5.8663 ymin: 47.2708 xmax: 15.0418 ymax: 55.0565
Geodetic CRS:  WGS 84
First 5 geometries:
MULTIPOLYGON (((8.35 47.5706, 8.3284 47.5712, 8...
MULTIPOLYGON (((11.4101 47.4954, 11.408 47.4911...
MULTIPOLYGON (((13.5002 52.6138, 13.4968 52.605...
MULTIPOLYGON (((13.3222 51.4367, 13.3258 51.433...
MULTIPOLYGON (((8.675 53.1781, 8.6757 53.1752, ...

I transform the geometry values from MULTIPLOYGONS to POLYGONS using sf's st_cast:

germany_polygon <- st_cast(germany_1, "POLYGON")

This is what I get:

Geometry set for 114 features 
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 5.8663 ymin: 47.2708 xmax: 15.0418 ymax: 55.0565
Geodetic CRS:  WGS 84
First 5 geometries:
POLYGON ((8.35 47.5706, 8.3284 47.5712, 8.3221 ...
POLYGON ((8.6801 49.6187, 8.6801 49.6203, 8.684...
POLYGON ((8.6741 47.6979, 8.6765 47.6979, 8.673...
POLYGON ((11.4101 47.4954, 11.408 47.4911, 11.3...
POLYGON ((13.5002 52.6138, 13.4968 52.6051, 13....

When I expand on the geometry, I expect to get "list of length 58", for example but all observations have "list of length 1". As such, there are no values to generate the tilegrams.

Also, dim(germany_polygon) gives [1] 114 12, but I expected similar levels as dim(germany_1) output [1] 16 12.

The purpose of this effort is to create a tilegram like this one from GADM data. Any directions are welcome.

5
  • The geoJSON gives you MULTIPOLYGON because some of the features (rows) are made up of multiple rings. See plot(germany_1$geometry[5]). If you convert to POLYGON you split these into single features. Why did you think you needed to do that?
    – Spacedman
    Aug 9 at 12:06
  • Are you trying to make exactly this: commons.wikimedia.org/wiki/…
    – Spacedman
    Aug 9 at 12:11
  • Yes, I want to make such an image linked from wikimedia. To your first question, I am assuming each of this single feature will be the hex/circle to be plot. After plotting plot(germany_1$geometry[5] I see what you mean by multiple rings. What should I do then? As a learner, I have tried reading multiple documentations around this issue but I do not know how to get that final image (like Wikipedia).
    – ma991ng
    Aug 9 at 14:32
  • Have you found a package that creates these sorts of cartograms? What input does it expect?
    – Spacedman
    Aug 9 at 15:39
  • Yes - this is the closest I found, TilegramsR: github.com/bhaskarvk/tilegramsR For example, class(sf_france_regions_population) is [1] "sf" "data.frame" Getting that data object right is what I have trying up there. I have not found any documentation or specifications on the expected object.
    – ma991ng
    Aug 9 at 16:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.