Easing into MapBox

Also:::: https://webkid.io/blog/mapbox-gl-data-visualization/

Installing the MapBox CLI proved challenging

The MapBox CLI is available on GitHub – running pip install mapbox-tilesets failed due to problem with installing rasterio – which couldn’t find gdal. After many failed attempts (using Conda etc), I came upon a solution that involved using “wheels” to install these requirements.

GDAL – download RASTERIO – download the rasterio‑1.2.1‑cp39‑cp39‑win_amd64.whl and run pip install rasterio-1.2.1-cp39-cp39-win_amd64.whl.

… and then install the MapBox CLI, running pip install mapbox-tilesets.

GeoJSON coordinate system

The MapBox CLI requires line-delimited GeoJSON files using the OGC: CRS84 coordinate reference system – that is, it must use longitude and latitude (in that order), decimal degrees, and the WGS84 coordinate system.

To generate line-delimited GeoJSON files meeting these requirements, we need to process the federal and provincial governments’ geodata files:

  1. Unzip a shapefile.
  2. Determine its coordinate system.
  3. Reproject to WGS84.
  4. Convert to line-delimited GeoJSON.

Step 1 is straightforward.

Step 2 is covered in a good overview of working with shapefiles. We install mapshaper, running npm install -g mapshaper. We can then convert our files, running mapshaper different_projection.shp -proj wgs84 -o format=geojson

Unhappily, the LHIN Subregions geodata file is in GBT format – we use https://mygeodata.cloud/result – a commercial service, to convert the *.zip to a shapefile and then proceed.

*prj files

File *.prj
cymh_service_areas_after_march_9_2015 GEOGCS[“GCS_North_American_1983”,DATUM[“D_North_American_1983”,SPHEROID[“GRS_1980”,6378137,298.257222101]],PRIMEM[“Greenwich”,0],UNIT[“Degree”,0.017453292519943295]]
Ministry_of_Health_Public_Health_Unit_Boundary-shp** GEOGCS[“GCS_WGS_1984”,DATUM[“D_WGS_1984”,SPHEROID[“WGS_1984”,6378137.0,298.257223563]],PRIMEM[“Greenwich”,0.0],UNIT[“Degree”,0.0174532925199433]]
lcd_000b16a_e PROJCS[“PCS_Lambert_Conformal_Conic”,GEOGCS[“GCS_North_American_1983”,DATUM[“D_North_American_1983”,SPHEROID[“GRS_1980”,6378137.0,298.257222101]],PRIMEM[“Greenwich”,0.0],UNIT[“Degree”,0.0174532925199433]],PROJECTION[“Lambert_Conformal_Conic”],PARAMETER[“False_Easting”,6200000.0],PARAMETER[“False_Northing”,3000000.0],PARAMETER[“Central_Meridian”,-91.86666666666666],PARAMETER[“Standard_Parallel_1”,49.0],PARAMETER[“Standard_Parallel_2”,77.0],PARAMETER[“Latitude_Of_Origin”,63.390675],UNIT[“Meter”,1.0]]
Municipal_Boundary_-_Lower_and_Single_Tier** GEOGCS[“GCS_WGS_1984”,DATUM[“D_WGS_1984”,SPHEROID[“WGS_1984”,6378137.0,298.257223563]],PRIMEM[“Greenwich”,0.0],UNIT[“Degree”,0.0174532925199433]]
Municipal_Boundary_-_Upper_Tier_and_District** GEOGCS[“GCS_WGS_1984”,DATUM[“D_WGS_1984”,SPHEROID[“WGS_1984”,6378137,298.257223563]],PRIMEM[“Greenwich”,0],UNIT[“Degree”,0.017453292519943295]]
HRL_035a18a_e PROJCS[“PCS_Lambert_Conformal_Conic”,GEOGCS[“GCS_North_American_1983”,DATUM[“D_North_American_1983”,SPHEROID[“GRS_1980”,6378137.0,298.257222101]],PRIMEM[“Greenwich”,0.0],UNIT[“Degree”,0.0174532925199433]],PROJECTION[“Lambert_Conformal_Conic”],PARAMETER[“False_Easting”,6200000.0],PARAMETER[“False_Northing”,3000000.0],PARAMETER[“Central_Meridian”,-91.86666666666666],PARAMETER[“Standard_Parallel_1”,49.0],PARAMETER[“Standard_Parallel_2”,77.0],PARAMETER[“Latitude_Of_Origin”,63.390675],UNIT[“Meter”,1.0]]
LHIN_Sub_Regions_Cartographic_AUGUST_2017.gdb-polygon (from GeoData online conversion) GEOGCS[“GCS_North_American_1983”,DATUM[“D_North_American_1983”,SPHEROID[“GRS_1980”,6378137,298.257222101]],PRIMEM[“Greenwich”,0],UNIT[“Degree”,0.017453292519943295]]
MCYS Integrated Regions GEOGCS[“GCS_North_American_1983”,DATUM[“D_North_American_1983”,SPHEROID[“GRS_1980”,6378137,298.257222101]],PRIMEM[“Greenwich”,0],UNIT[“Degree”,0.017453292519943295]]
** denotes files already in WGS84

 

 

  1. 7 MB