This article was originally posted on May 14, 2016 and revised on July 28, 2016 to take account of changes in the geospatial representation of Children and Youth Mental Health Service Areas in Ontario. For more details, see … and then there were 33.
In 2014-15, the Ministry of Children and Youth Services (MCYS) defined two administrative views of mental health services for children and youth in Ontario:
The provincial government has published geospatial data for the MCYS’s Integrated Service Regions (ISRs) and Children and Youth Mental Health Service Areas (CYMHSAs) in Shapefile format. Here, we’ll work only with the geospatial data for the ISRs.
The Shapefile archive for the ISRs (mcys_integrated_regions.zip) contains four files:
- mcys_integrated_regions.shp — shape format
- mcys_integrated_regions.shx — shape index format
- mcys_integrated_regions.dbf — attribute format
- mcys_integrated_regions.prj — projection format: the coordinate system and projection information, expressed in well-known text format
For ease of reference, we rename the four mcys_integrated_regions.* files isrs.*.
Converting Shapefiles to GeoJSON format
To use d3.geo to visualize the ISRs, we first convert the Shapefiles to GeoJSON format files, using ogr2ogr. There are three steps:
- Determine the Spatial Reference System (SRS) used by the Shapefile
- Set the -t_srs switch in ogr2ogr to output the GeoJSON file using this SRS
- Rename variables for ease of use
The projection format file for the ISRs specifies:
We use Prj2EPSG, a simple online service to convert the projection information contained in the .prj file into standard EPSG codes for the corresponding spatial reference system. From this we determine that the specification contained in isrs.prj corresponds to EPSG 4269 – GCS_North_American_1983.
We now use the -t_srs switch in ogr2ogr to transform the output using the spatial reference system specified in isrs.prj:
ogr2ogr -t_srs EPSG:4269 -f GeoJSON isrs_geo.json isrs.shp
The GeoJSON format file is isrs_geo.json.
Finally, we use a text editor to give more meaningful names to a few variables in the GeoJSON files and to express them in all lowercase letters:
|Original variable||Modified variable|
Converting GeoJSON files to TopoJSON format
We use topojson to convert the GeoJSON file isrs_geo.json to a TopoJSON format file:
topojson -o isrs_topo.json --id-property region_name --properties -- isrs_geo.json
The --id-property switch in topojson is used to promote the feature property "region_name" to geometry id status in the TopoJSON file isrs_topo.json.
We may now visualize the MCYS Integrated Service Regions by applying d3.geo to isrs_topo.json.