=== modified file 'src/docbkx/en/dhis2_user_man_creating_gis.xml' --- src/docbkx/en/dhis2_user_man_creating_gis.xml 2011-02-02 13:14:10 +0000 +++ src/docbkx/en/dhis2_user_man_creating_gis.xml 2011-02-03 16:40:10 +0000 @@ -1,211 +1,224 @@ - - - - GIS -
- OpenHealthMapper - The DHIS 2 GIS web module is inspired by the WHO HealthMapper desktop application. -
-
- Setting up the GIS module -
- Importing geographical layers for orgunit thematic mapping - The maps are generated off the coordinates information linked to the Organisation Units in the database. No additional files are needed. As soon as the orgunits have coordinates the maps will be available in the GIS module. Although it is possible to add/edit coordinates directly in the Edit Organisation Unit window (in Maintenance->Organisation Unit) we recommend doing this in a batch job using the general import process in the import/export module. The import process will need a GML file with at least the two properties; "Name" and "coordinates". - To generate the GML file start by installing the open source tool called ogr2ogr. This should be available for most Linux distros ("sudo apt-get install -gdal-bin"). For Windows, get FWTools: http://fwtools.maptools.org/ - The most common format for GIS data is the ESRI shapefile, which consists of three identically named files with extensions .shp, .shx and .dbf. -(You can use ogr2ogr to convert between any formats, see example below). Open the .dbf in a spreadsheet application (e.g. MS Excel). Make sure - there is a field (column) called "Name" which has orgunit names, and that these orgunits are already existing in DHIS2. Also make sure all spellings are identical since the matching is done on this name. - - On Windows, open the FWTools Shell and navigate to the folder with the shapefile. Issue the following command (replace "output" and -"input" with the actual names): - ogr2ogr -F GML output.gml input.shp - - The column in the .dbf file with the orgunit name will have been converted to an XML element inside the GML file. Open the GML file in -a text editor (e.g. Notepad++) and do a search/replace to make sure this element is called exactly ogr:Name (case sensitive), e.g. -<ogr:Name>Badjia</ogr:Name> - - Import the GML file into DHIS2 through the import process in the import/export module (under services menu). There is no need to zip the file. Change import type to "preview" before doing the import to see which changes that will be made and resolve any issues with orgunit name matching etc. See the import/export chapter in the manual for more details on import processes. After import the coordinates will be added to the orgunit's metadata and also be available from the orgunit edit window (Maintenance->Organisation Units). -
-
-
- Administering the GIS module -
- Administrator settings - The administrator settings window can be opened from the map toolbar, click on the wrench symbol (tooltip says "Administrator settings"). Here you can define the Date Type used to select periods. Either use fixed periods corresponding to the periods used in DHIS data collection (weeks, months, quarters, 6-months, years etc.) or use the more flexible start and end dates. -
-
- Register overlays - Overlays are geographical layers that do not have any direct linkage - to data in the database. Examples include roads, rivers, airports, ports, - and other geographical information that you may want to display on your - map, but that is not necessarily linked to data contained in the DHIS - database. The Register Overlay panel will allow you to - add new layers and determine how they will be represented visually on the - map. - - - Display name: Represents your overlay in - the layer tree in the upper right corner. - - - Map source file: The GeoJSON file - name. - - - Fill color: Decides the fill color if the - layer is a polygon layer. - - - Fill opacity: Select an opacity level - between 0 (invisible) and 1 (solid). - - - Stroke color: The stroke color over lines - and polygon borders. - - - Stroke width: Select a stroke width between - 0 and 4. - - -
- Copying files to the DHIS application - Currently, your GeoJSON files should be placed in the - DHIS2_HOME/geojson of your DHIS application to be accessible to the GIS - module. If the GeoJSON directory does not exist, you will need to create - it manually and copy your GeoJSON files there. -
-
-
-
- Background information -
- Identifying map data - Geographical data can be divided in two basic groups - raster and vector. -
- Raster images - Raster can be thought of as pictures such as satellite images. Images can be used as background for maps, and the OHM can pull them in from any standard compliant - Web Map Service (WMS). It is also of great interest to - combine the DHIS2 installation with a GeoServer instance, - which can be downloaded as a .war-file and run in the same servlet container (e.g. Tomcat, Jetty, Resin). Geoserver can provide - both background layers such as roads, lakes etc. or also display thematic data as an alternative to the browser-rendered - main mode which uses GeoJSON. -
-
- Vector data - In order to create thematic maps (also known as choropleth maps) - we need to have vector polygons (e.g. for facility catchment areas or administrative regions). Also, vector files are required for - points (e.g. health facility locations or even different wards within a hospital). Such vector files consist of a collection of (x,y) - coordinates with a number of associated attributes (at least a name). Vector data can come in a lot of formats, such as GPS - coordinates for facilities. The most common is the ESRI shapefile format. - In order to make web maps interactive, DHIS 2 uses the javascript GeoJSON format. -
-
- Getting data - - In order to use the OHM with DHIS2, it is necessary to have vector data for each orgunit level one wants to see in the map. - In many countries, the Ministry of Health will have shapefiles for the health-related administrative divisions. In other cases, - such files may have to be procured from a ministry of planning or from private vendors. Facility coordinates can easily be - assembled into a layer (file) for facilities - and if they are not available, these can be collected by cheap GPS units (increasingly - available also in mobile phones). Additionally, a lot of data are available freely on the web - especially bacground layers and - overlays, but also facility positions and administrative boundaries. Below is a list of sources of such data: - - - OpenStreetMap - - - Handling the layers - - - Maplibrary - - - Global Administrative Areas - - - UN organizations, especially WHO and FAO, have administrative boundaries - - -
-
- Projections - DHIS 2 uses latitude/longitude (lat/lon) coordinates in the standard EPSG:4326 projection, which is - very widespread. But it is also common to get data in UTM formats [http://en.wikipedia.org/wiki/ - Universal_Transverse_Mercator_coordinate_system]. For example, data for Malawi is often distributed as UTM 36S - projection, which corresponds to EPSG:2736. The conversion can be done by be done by using either Geoserver or ogr2ogr - wich is part of GDAL and comes with Ubuntu. For Windows, it comes as part of FW Tools . For example, the following line will convert a shapefile - called inputfile.shp in UTM 36S projection to a GeoJSON file in lat/lon: - ogr2ogr s_srs EPSG:2736 a_srs EPSG:4326 -f "GeoJSON" outputfile.json inputfile.shp - -
-
- GIS software to view and manipulate map data - There are many powerful free and open source GIS packages. We recommend the following: - - - Quantum GIS - - - OpenJUMP - - - uDig, which also forms basis for DIVA-GIS - - - gvSIG - - - These tools can for example be used to merge village boundary polygons into district polygons (provided the district that each village belongs to is listed as an attribute), and - one can edit files to reflect new divisions or correct errors. - Another power tool for working with GIS data is PostGIS, which can be used on itself or in conjunction - with the above applications. - -
-
-
- Conversion of geographical data to GeoJSON format - The DHIS2 mapping client relies on GeoJSON files in order to display - a map in the browser window. Often times, geographical data is received in - many different formats, but the ESRI shape file format is one of the most - common. Several procedures will be described below. It is important, but - not required, that the names in your geographical data match those in the - DHIS2 organisational hierarchy. If they do not, you will need to manually - match them in a later step -
- Production of GeoJSON files with GDAL - GDAL is a multi-platform toolkit for the manipulation of - geographical data. It is freely available for a wide-range of platforms - at http://gdal.org - Production of GeoJSON files are straightforward with GDAL. Just - execute (on Windows) - ogr2ogr.exe -f "GeoJSON" dst_datasource_name src_datasource_name - or on Linuxogr2ogr -f "GeoJSON"dst_datasource_name src_datasource_name - Replace dst_datasource_name with the path - to the destination geographical data file (following the naming - convention described above) and - src_datasource_name with the source geographical - data file. Take note that you may need to specify input and output coordinate systems as described above. -
-
- Using Geoserver - Geoserver is capable of outputting GeoJSON formats. If you have - geoserver running someplace, you can execute the following query. - http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typename=topp:states&outputformat=json&srs_name=EPSG:4326 - Take note that you need to specify the spatial coordinate system. By default, Geoserver will return GeoJSON files with the format "long/lat" while -the DHIS mapping client expects the ordering of the coordinates in "lat/long" format. The explicit declaration of the spatial reference system will ensure that coordinates are returned in the proper order. At the time of writing, the DHIS mapping client does not support spatial reference systems other than EPSG 4326. If you are using Geoserver, the application will handle the reprojection from the native format of the geographical data to EPSG 4326. If you are using other methods as described below to generate the GeoJSON file, you will need to ensure that the GeoJSON output is set to EPSG 4326 (Geographical Lat/long). - You will need to adjust the host destination if the machine is not - your local machine as well as defining the actual layer in Geoserver - which should be output to GeoJSON (in this case - topp:states). - Upon execution of the URL, Geoserver will produce a GeoJSON file, - and you will be asked to save it. Once it has finished downloading, - rename the file following the suggested naming convention: - ISO2CountryCode followed by an underscore, followed by the layer - type (e.g. “admin” for administrative layers, “health” for health - administrative boundaries). For instance, the first administrative layer - for Zambia would be named as "zm_admin1". -
-
-
-
+ + + + GIS +
+ OpenHealthMapper + The DHIS 2 GIS web module is inspired by the WHO HealthMapper desktop application. +
+
+ Setting up the GIS module +
+ Importing geographical layers for orgunit thematic mapping with GML + The maps are generated off the coordinates information linked to the Organisation Units in the database. No additional files are needed. As soon as the orgunits have coordinates the maps will be available in the GIS module. Although it is possible to add/edit coordinates directly in the Edit Organisation Unit window (in Maintenance->Organisation Unit) we recommend doing this in a batch job using the general import process in the import/export module. The import process will need a GML file with at least the two properties; "Name" and "coordinates". + To generate the GML file start by installing the open source tool called ogr2ogr. This should be available for most Linux distros ("sudo apt-get install +gdal-bin"). For Windows, get FWTools: http://fwtools.maptools.org/ + The most common format for GIS data is the ESRI shapefile, which consists of three identically named files with extensions .shp, .shx and .dbf. +(You can use ogr2ogr to convert between any formats, see example below). Open the .dbf in a spreadsheet application (e.g. MS Excel). Make sure + there is a field (column) called "Name" which has orgunit names, and that these orgunits are already existing in DHIS2. Also make sure all spellings are identical since the matching is done on this name. + + On Windows, open the FWTools Shell and navigate to the folder with the shapefile. Issue the following command (replace "output" and +"input" with the actual names): + ogr2ogr -F GML output.gml input.shp + + The column in the .dbf file with the orgunit name will have been converted to an XML element inside the GML file. Open the GML file in +a text editor (e.g. Notepad++) and do a search/replace to make sure this element is called exactly ogr:Name (case sensitive), e.g. +<ogr:Name>Badjia</ogr:Name> + + Import the GML file into DHIS2 through the import process in the import/export module (under services menu). There is no need to zip the file. Change import type to "preview" before doing the import to see which changes that will be made and resolve any issues with orgunit name matching etc. See the import/export chapter in the manual for more details on import processes. After import the coordinates will be added to the orgunit's metadata and also be available from the orgunit edit window (Maintenance->Organisation Units). +
+
+
+ Administering the GIS module +
+ Administrator settings + The administrator settings window can be opened from the map toolbar, click on the wrench symbol (tooltip says "Administrator settings"). Here you can define the Date Type used to select periods. Either use fixed periods corresponding to the periods used in DHIS data collection (weeks, months, quarters, 6-months, years etc.) or use the more flexible start and end dates. +
+
+ Register overlays + Overlays are geographical layers that do not have any direct linkage + to data in the database. Examples include roads, rivers, airports, ports, + and other geographical information that you may want to display on your + map, but that is not necessarily linked to data contained in the DHIS + database. The Register Overlay panel will allow you to + add new layers and determine how they will be represented visually on the + map. + + + Display name: Represents your overlay in + the layer tree in the upper right corner. + + + Map source file: The GeoJSON file + name. + + + Fill color: Decides the fill color if the + layer is a polygon layer. + + + Fill opacity: Select an opacity level + between 0 (invisible) and 1 (solid). + + + Stroke color: The stroke color over lines + and polygon borders. + + + Stroke width: Select a stroke width between + 0 and 4. + + +
+ Copying files to the DHIS application + Currently, your GeoJSON files should be placed in the + DHIS2_HOME/geojson of your DHIS application to be accessible to the GIS + module. If the GeoJSON directory does not exist, you will need to create + it manually and copy your GeoJSON files there. +
+
+
+
+ Background information +
+ Identifying map data + Geographical data can be divided in two basic groups - raster and vector. +
+ Raster images + Raster can be thought of as pictures such as satellite images. Images can be used as background for maps, and the OHM can pull them in from any standard compliant + Web Map Service (WMS). It is also of great interest to + combine the DHIS2 installation with a GeoServer instance, + which can be downloaded as a .war-file and run in the same servlet container (e.g. Tomcat, Jetty, Resin). Geoserver can provide + both background layers such as roads, lakes etc. or also display thematic data as an alternative to the browser-rendered + main mode which uses GeoJSON. +
+
+ Vector data + In order to create thematic maps (also known as choropleth maps) + we need to have vector polygons (e.g. for facility catchment areas or administrative regions). Also, vector files are required for + points (e.g. health facility locations or even different wards within a hospital). Such vector files consist of a collection of (x,y) + coordinates with a number of associated attributes (at least a name). Vector data can come in a lot of formats, such as GPS + coordinates for facilities. The most common is the ESRI shapefile format. + In order to make web maps interactive, DHIS 2 uses the javascript GeoJSON format. +
+
+ Getting data + + In order to use the OHM with DHIS2, it is necessary to have vector data for each orgunit level one wants to see in the map. + In many countries, the Ministry of Health will have shapefiles for the health-related administrative divisions. In other cases, + such files may have to be procured from a ministry of planning or from private vendors. Facility coordinates can easily be + assembled into a layer (file) for facilities - and if they are not available, these can be collected by cheap GPS units (increasingly + available also in mobile phones). Additionally, a lot of data are available freely on the web - especially bacground layers and + overlays, but also facility positions and administrative boundaries. Below is a list of sources of such data: + + + OpenStreetMap + + + Handling the layers + + + Maplibrary + + + Global Administrative Areas + + + UN organizations, especially WHO and FAO, have administrative boundaries + + +
+
+ Projections + DHIS 2 uses latitude/longitude (lat/lon) coordinates in the standard EPSG:4326 projection, which is + very widespread. But it is also common to get data in UTM formats [http://en.wikipedia.org/wiki/ + Universal_Transverse_Mercator_coordinate_system]. For example, data for Malawi is often distributed as UTM 36S + projection, which corresponds to EPSG:2736. The conversion can be done by be done by using either Geoserver or ogr2ogr + wich is part of GDAL and comes with Ubuntu. For Windows, it comes as part of FW Tools . For example, the following line will convert a shapefile + called inputfile.shp in UTM 36S projection to a GeoJSON file in lat/lon: + ogr2ogr s_srs EPSG:2736 a_srs EPSG:4326 -f "GeoJSON" outputfile.json inputfile.shp + +
+
+ GIS software to view and manipulate map data + There are many powerful free and open source GIS packages. We recommend the following: + + + Quantum GIS + + + OpenJUMP + + + uDig, which also forms basis for DIVA-GIS + + + gvSIG + + + These tools can for example be used to merge village boundary polygons into district polygons (provided the district that each village belongs to is listed as an attribute), and + one can edit files to reflect new divisions or correct errors. + Another power tool for working with GIS data is PostGIS, which can be used on itself or in conjunction + with the above applications. + +
+
+
+ Conversion of geographical data to GeoJSON format + The DHIS2 mapping client relies on GeoJSON files in order to display + a map in the browser window. Often times, geographical data is received in + many different formats, but the ESRI shape file format is one of the most + common. Several procedures will be described below. It is important, but + not required, that the names in your geographical data match those in the + DHIS2 organisational hierarchy. If they do not, you will need to manually + match them in a later step +
+ Production of GeoJSON files with GDAL + GDAL is a multi-platform toolkit for the manipulation of + geographical data. It is freely available for a wide-range of platforms + at http://gdal.org + Production of GeoJSON files are straightforward with GDAL. Just + execute (on Windows) + ogr2ogr.exe -f "GeoJSON" dst_datasource_name src_datasource_name + or on Linuxogr2ogr -f "GeoJSON"dst_datasource_name src_datasource_name + Replace dst_datasource_name with the path + to the destination geographical data file (following the naming + convention described above) and + src_datasource_name with the source geographical + data file. Take note that you may need to specify input and output coordinate systems as described above. +
+
+ Using Geoserver + Geoserver is capable of outputting GeoJSON formats. If you have + geoserver running someplace, you can execute the following query. + http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typename=topp:states&outputformat=json&srs_name=EPSG:4326 + Take note that you need to specify the spatial coordinate system. By default, Geoserver will return GeoJSON files with the format "long/lat" while +the DHIS mapping client expects the ordering of the coordinates in "lat/long" format. The explicit declaration of the spatial reference system will ensure that coordinates are returned in the proper order. At the time of writing, the DHIS mapping client does not support spatial reference systems other than EPSG 4326. If you are using Geoserver, the application will handle the reprojection from the native format of the geographical data to EPSG 4326. If you are using other methods as described below to generate the GeoJSON file, you will need to ensure that the GeoJSON output is set to EPSG 4326 (Geographical Lat/long). + You will need to adjust the host destination if the machine is not + your local machine as well as defining the actual layer in Geoserver + which should be output to GeoJSON (in this case + topp:states). + Upon execution of the URL, Geoserver will produce a GeoJSON file, + and you will be asked to save it. Once it has finished downloading, + rename the file following the suggested naming convention: + ISO2CountryCode followed by an underscore, followed by the layer + type (e.g. “admin” for administrative layers, “health” for health + administrative boundaries). For instance, the first administrative layer + for Zambia would be named as "zm_admin1". +
+
+ Production of GeoJSON with PostGIS + In certain situations, direct updates of the coordinates which are stored via a database query may be needed or desireable. The coordinate which are accepted by DHIS2 are similar to a normal GeoJSON clause for a geographical object with a few minor modifications. GeoJSON can be rather easily produced from a PostGIS database with a simple query as shown below. + CREATE OR REPLACE VIEW districts_as_geojson AS + SELECT district::character varying(230) AS name, + substring(st_asgeojson(1, geom, 4) from 38 for(length(st_asgeojson(1,geom,4)) - 38 )) + AS coordinates + FROM district_geometry; + + Basically, all the query does is to produce version 1 GeoJSON from the geometry column (in this case named "geom") and strip oeut some initial and final text which DHIS2 generates automatically when it assembled a group of geometrical objects for presentation on the GIS. The paramater of hte st_asgeojson command also allows you to control the number of decimal + Once this is created as a view in your DHIS2 database, you can issue a simple update statement to automatically update the coordinates. + UPDATE organisationunit a SET coordinates = b.coordinates from districts_as_geojson b where a.name = b.name; +
+
+
+