← Back to team overview

dhis2-devs team mailing list archive

GIS - thematic layers only through GML import

 

The latest improvement of the GIS module means we now have the ability
to make maps for a limited area of a country (e.g. a province) but
also select what level that should be visible for this area (e.g.
districts or subdistricts). This means that having polygon coordinates
in the orgunit table now provides more functionality than the previous
method of fetching separate GeoJSON file layers for each level from
the file system, which now seems redundant. I think it therefore may
be time to remove the functionality which supports these "external"
files, since the process of converting the common shapefile format to
GeoJSON and uploading is very similar to converting to GML and
uploading.

This means that people will no longer have make the somewhat confusing
choise of a mode for thematic layers ("GeoJSON or database"), and we
can remove the functionality of visually matching polygons to orgunits
in the database. However, we should keep the ability to add
non-thematic layers as GeoJSON files for overlays (e.g. roads, rivers,
cities, airports). Such additional layers (as well as background
layers) can also be added as WMS  using a local Geoserver or external
services.

Also, there are questions as to maintenance of orgunit polygons as
administrative boundaries change. And perhaps most importantly, it
would be very nice to be able to create the orgunit hierarchy based on
shapefiles, rather than having to ensure the hierarchy is already in
DHIS2 and matches the shapefile names (see below). I think we should
encourage the use of a "Parent" column in the DBF file, and add the
ability to recognize this column in the GML import. Alternatively, I
suppose we could describe a good method to create the hierarchy in
Excel based on a collection of DBF files.

In order to link with other data, it would also be good if the
OpenHealthMapper interface would also be able to specify thematic maps
from a service like Geoserver, but that may be a larger effort.

The documentation also needs to be updated to reflect the new import
method. Below is a description of the current process importing from
shape files. Though this is not something people do very often, we
should probably aim to simplify it over the medium term.

1. First you need to make sure that all the orgunits for which you are
adding polygons are in DHIS2, and that there is a field in each .dbf
file which has this name. The spelling must be identical for DHIS2 to
be able to match, so change any deviant spellings.

2. You then need to use the free tool ogr2ogr to convert your
shapefiles into GML format. On Linux you can just do apt-get install
ogr2ogr.
For Windows, you should download FWTools, http://fwtools.maptools.org/

3. Now open a command window and navigate to the folder with the
shapefiles, and issue the following command (replace "output" and
"input" with the actual names):
ogr2ogr -F GML output.gml input.shp

4. 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>

5. Import the GML file into DHIS through the regular import interface
(no need to zip it)

6. In the GIS module, make sure the Administrator - Map Source setting
is set to DHIS database.

In the Polygon Layer screen, you can then select the orgunit from the
tree which appears by clicking on the Parent orgunit field.



Follow ups