Quebec floodable areas could use an update...
UPDATE 2020: addr.country, n’existe plus dans les buildings de osm data. aussi il faut faire st_collection_extract(type=“POLYGON”) car mes intersections ont commencé à retourner des geometry collection This morning I heard an annoucement from the provincial government telling me that preparing for floods is my responsibility, that I should check if my house is in a floodable area and that I should visit quebec.ca/inondations for more information.
We currently have multiple major flooding events in the city of Gatineau. I used open data about buildings (package osmdata), floodable area and flooded areas to figure out what percentage of flooded homes actually are in a floodable area. Turns out that more than half of the flooded homes were outside the floodable areas and had no reason to prepare.
This is a dangerous situation and definitely needs fixing.
As usual, the code is available on github. Code snippets I will be coming back to involve the chain were I dropped the worst polygons using st_is_valid(reason=TRUE), fixed the fixable polygons using st_make_valid(), then casted the result usint st_cast(“MULTIPOLYGON”) to make everything digestable by leaflet. Another useful snippet is names(st_geometry(all_builds )) = NULL , because the data generated by osmdata_sf has named geometry, which leaflet doesnt like.