1

I am trying to create a chorpleth of Belgium in shiny (R) using this geojson file (github view). I am following the tutorial of rstudio to get the basics right. While doing this I encountered the following error while trying to use the geojsonio::geojson_read() function.

Error: Multiple incompatible geometries: wkbPolygon: 586; wkbGeometryCollection: 3

After some debugging I found that, indeed there are 3 GeometryCollections. However these collections are municipalities that have enclaves (multiple polygons for one municipality). One of which it the famous border craziness of Baarle Hertog/Baarle-Nassau. So both wkbPloygons and wkbGeometryCollection should be inside the same layer for plotting.

What would be the easiest way to accomplish this?

Robin VdE
  • 77
  • 2
  • 8
  • How do you produce your GeoJSON? Normally, it should contains MultiPolygon. GeometryCollection are not needed to manage enclaves. I have generated GeoJSON from http://www.atlas-belgique.be/cms2/index.php?page=cartodata_fr and the output is Multipolygon only https://gist.github.com/ThomasG77/ab994f805627c4c121615455ded949d7 (GeoJSON not simplified and with different attributes) – Thomas Gratier May 24 '18 at 14:14
  • Can you try to install dev version of `geojsonio` like `remotes::install_github("ropensci/geojsonio")`. it works for me. – sckott May 24 '18 at 14:17
  • `sf <- sf::st_read(geojson_url); sf <- geojsonsf::geojson_sf(geojson_url)` both also work for reading GeoJSON, and both give you an `sf` object – SymbolixAU Jun 01 '18 at 22:30

0 Answers0