<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium/"></div></div><div><a data-url="https://www.r-bloggers.com/belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium/" data-counturl="https://www.r-bloggers.com/belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium/" data-count="horizontal" data-text="BelgiumMaps.StatBel: R package with Administrative boundaries of Belgium" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.bnosac.be/index.php/blog/61-belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium"> BNOSAC - Belgium Network of Open Source Analytical Consultants</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>We recently opened up the<span> </span><strong>BelgiumMaps.StatBel</strong><span> </span>package and made it available at <a target="_blank" rel="nofollow" href="https://github.com/bnosac/BelgiumMaps.StatBel">https://github.com/bnosac/BelgiumMaps.StatBel</a>. This R package contains maps with administrative boundaries (national, regions, provinces, districts, municipalities, statistical sectors, agglomerations (200m)) of Belgium extracted from Open Data at Statistics Belgium. </p>
<p><img alt="belgiummaps statbel" src="https://i1.wp.com/www.bnosac.be/images/blog/belgiummaps_statbel.png?resize=397%2C287" data-recalc-dims="1"></p>
<p>The package is a data-only package where maps of administrative zones in Belgium are available in the WGS84 coordinate reference system. The data is available in several objects:</p>
<p>BE_ADMIN_SECTORS: a SpatialPolygonsDataFrame with polygons and data at the level of the statistical sector<br>BE_ADMIN_MUNTY: a SpatialPolygonsDataFrame with polygons and data at the level of the municipality<br>BE_ADMIN_DISTRICT: a SpatialPolygonsDataFrame with polygons and data at the level of the district<br>BE_ADMIN_PROVINCE: a SpatialPolygonsDataFrame with polygons and data at the level of the province<br>BE_ADMIN_REGION: a SpatialPolygonsDataFrame with polygons and data at the level of the region<br>BE_ADMIN_BELGIUM: a SpatialPolygonsDataFrame with polygons and data at the level of the whole of Belgium<br>BE_ADMIN_HIERARCHY: a data.frame with administrative hierarchy of Belgium<br>BE_ADMIN_AGGLOMERATIONS: a SpatialPolygonsDataFrame with polygons and data at the level of an agglomeration (200m)</p>
<p>The core data of the package contains administrative boundaries at the level of the statistical sector which can easily be plotted using the sp or the leaflet package.</p>
<div>
<pre>library(BelgiumMaps.StatBel)<br>data(BE_ADMIN_SECTORS)<br>bxl &lt;- subset(BE_ADMIN_SECTORS, TX_RGN_DESCR_NL %in% &quot;Brussels Hoofdstedelijk Gewest&quot;)<br>plot(bxl, main = &quot;NIS sectors in Brussels&quot;)</pre>
</div>
<p><img alt="bxl sectors" src="https://i1.wp.com/www.bnosac.be/images/blog/bxl_sectors.png?resize=291%2C317" data-recalc-dims="1"></p>
<p>All municipalities, districts, provinces, regions and country level boundaries are also directly available in the package.</p>
<div>
<pre>data(BE_ADMIN_SECTORS)<br>data(BE_ADMIN_MUNTY)<br>data(BE_ADMIN_DISTRICT) <br>data(BE_ADMIN_PROVINCE) <br>data(BE_ADMIN_REGION) <br>data(BE_ADMIN_BELGIUM) <br>plot(BE_ADMIN_MUNTY, main = &quot;Belgium municipalities/districts/provinces&quot;)<br>plot(BE_ADMIN_DISTRICT, lwd = 2, add = TRUE)<br>plot(BE_ADMIN_PROVINCE, lwd = 3, add = TRUE)
</pre>
</div>
<p><img alt="belgium municipalities" src="https://i2.wp.com/www.bnosac.be/images/blog/belgium_municipalities.png?resize=332%2C308" data-recalc-dims="1"></p>
<p>The package also integrates well with other public data from Statistics Belgium as it contains spatial identifiers (nis codes, nuts codes) which you can use to link to other datasets. The following R code example creates an interactive map displaying net taxable income by statistical code for Brussels.</p>
<p>If you are looking for mapping data about Belgium, you might also be interested in the BelgiumStatistics package (which can be found at <a target="_blank" rel="nofollow" href="https://github.com/weRbelgium/BelgiumStatistics">https://github.com/weRbelgium/BelgiumStatistics</a>) containing more general statistics about Belgium or the BelgiumMaps.OpenStreetMap package (<a target="_blank" rel="nofollow" href="https://github.com/weRbelgium/BelgiumMaps.OpenStreetMap">https://github.com/weRbelgium/BelgiumMaps.OpenStreetMap</a>) which contains geospatial data of Belgium regarding landuse, natural, places, points, railways, roads and waterways, extracted from OpenStreetMap</p>
<div>
<pre>library(BelgiumMaps.StatBel)<br>library(leaflet)<br><br>## Get taxes / statistical sector<br>tempfile &lt;- tempfile()<br>download.file(&quot;http://statbel.fgov.be/nl/binaries/TF_PSNL_INC_TAX_SECTOR_tcm325-278417.zip&quot;, tempfile)<br>unzip(tempfile, list = TRUE)<br>taxes &lt;- read.table(unz(tempfile, filename = &quot;TF_PSNL_INC_TAX_SECTOR.txt&quot;), sep=&quot;|&quot;, header = TRUE, <br>                    encoding = &quot;UTF-8&quot;, stringsAsFactors = FALSE, quote = &quot;&quot;, na.strings = c(&quot;&quot;, &quot;C&quot;))<br>colnames(taxes)[1] &lt;- &quot;CD_YEAR&quot;<br><br>## Get taxes in last year<br>taxes &lt;- subset(taxes, CD_YEAR == max(taxes$CD_YEAR))<br>taxes &lt;- taxes[, c(&quot;CD_YEAR&quot;, &quot;CD_REFNIS_SECTOR&quot;, <br>                   &quot;MS_NBR_NON_ZERO_INC&quot;, &quot;MS_TOT_NET_TAXABLE_INC&quot;, &quot;MS_AVG_TOT_NET_TAXABLE_INC&quot;, <br>                   &quot;MS_MEDIAN_NET_TAXABLE_INC&quot;, &quot;MS_INT_QUART_DIFF&quot;, &quot;MS_INT_QUART_COEFF&quot;, <br>                   &quot;MS_INT_QUART_ASSYM&quot;)]<br><br>## Join taxes with the map<br>data(BE_ADMIN_SECTORS, package = &quot;BelgiumMaps.StatBel&quot;)<br>data(BE_ADMIN_DISTRICT, package = &quot;BelgiumMaps.StatBel&quot;)<br>data(BE_ADMIN_MUNTY, package = &quot;BelgiumMaps.StatBel&quot;)<br>str(BE_ADMIN_SECTORS@data)<br>mymap &lt;- merge(BE_ADMIN_SECTORS, taxes, by = &quot;CD_REFNIS_SECTOR&quot;, all.x=TRUE, all.y=FALSE)<br>mymap &lt;- subset(mymap, TX_RGN_DESCR_NL %in% &quot;Brussels Hoofdstedelijk Gewest&quot;)<br><br>## Visualise the data<br>pal &lt;- colorBin(palette = rev(heat.colors(11)), domain = mymap$MS_AVG_TOT_NET_TAXABLE_INC, <br>                bins = c(0, round(quantile(mymap$MS_AVG_TOT_NET_TAXABLE_INC, na.rm=TRUE, probs = seq(0.1, 0.9, by = 0.1)), 0), +Inf),<br>                na.color = &quot;#cecece&quot;)<br>m &lt;- leaflet(mymap) %>%<br>  addTiles() %>%<br>  addLegend(title = &quot;Net Taxable Income (EURO)&quot;, pal = pal, values = ~MS_AVG_TOT_NET_TAXABLE_INC, position = &quot;bottomleft&quot;, na.label = &quot;Missing&quot;) %>%<br>  addPolygons(color = ~pal(MS_AVG_TOT_NET_TAXABLE_INC), stroke = FALSE, smoothFactor = 0.2, fillOpacity = 0.85, <br>              popup = sprintf(&quot;%s: %s&lt;br>%s: %s&lt;br>&lt;br>%s €: Average net taxable income&lt;br>%s €: Median net taxable income&lt;br>%s declarations&quot;, <br>                              mymap$TX_SECTOR_DESCR_NL, mymap$TX_MUNTY_DESCR_NL, <br>                              mymap$TX_SECTOR_DESCR_FR, mymap$TX_MUNTY_DESCR_FR,  <br>                              mymap$MS_AVG_TOT_NET_TAXABLE_INC, mymap$MS_MEDIAN_NET_TAXABLE_INC, <br>                              mymap$MS_NBR_NON_ZERO_INC))<br>#m &lt;- addPolylines(m, data = BE_ADMIN_DISTRICT, weight = 1.5, color = &quot;black&quot;)<br>m &lt;- addPolylines(m, data = subset(BE_ADMIN_MUNTY, TX_RGN_DESCR_NL %in% &quot;Brussels Hoofdstedelijk Gewest&quot;), weight = 1.5, color = &quot;black&quot;)<br>m
 </pre>
</div>
<div>
<p><img alt="bxl income" src="https://i0.wp.com/www.bnosac.be/images/blog/bxl_income.png?resize=456%2C330" data-recalc-dims="1"></p>
<p> </p>
<p><strong>If you are interested in all of this, you might be interested also in attending our course on Applied Spatial Modelling with R which will be held at LStat (Leuven, Belgium) on  8-9 December 2016. More information: <a target="_blank" rel="nofollow" href="https://lstat.kuleuven.be/training/applied-spatial-modelling-with-r"></a><a target="_blank" rel="nofollow" href="https://lstat.kuleuven.be/training/applied-spatial-modelling-with-r">https://lstat.kuleuven.be/training/applied-spatial-modelling-with-r</a></strong></p>
<p><strong> </strong></p>
</div>
<div><strong><span>For all other enquiries:  <a target="_blank" rel="nofollow" href="http://www.bnosac.be/index.php/contact/mail-us">Get in touch</a></span></strong></div>
</div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium/"></div></div><div><a data-url="https://www.r-bloggers.com/belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium/" data-counturl="https://www.r-bloggers.com/belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium/" data-count="vertical" data-text="BelgiumMaps.StatBel: R package with Administrative boundaries of Belgium" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.bnosac.be/index.php/blog/61-belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium"> BNOSAC - Belgium Network of Open Source Analytical Consultants</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/moIYnX9d8HY"></a></div>