← Back to team overview

dhis2-users team mailing list archive

Re: GML Files

 

Hi Muhammad,

I recently made a .gml file for a Sri Lankan project which involved over
14500 org units. Since you have not specified, I hope you must be already
having the org units setup in your DHIS2 instance. In that case you can
follow the method below. Most of this detail is in user manual.

1. You need to have shape files for the org units your gonna use. Make sure
shape file attributes have a field which bears the same org unit name that
relates to the geographic boundary in the shapefile.

2. You need to use a tool called mapshaper. (http://mapshaper.org). you
should select the shape file you want to extract GIS location data from.
once uploaded it will preview the geographic boundary related to that shape
file.

3. drag and drop .dbf file that comes with the shape file on to the
mapshaper window. it contains all attribute data. Then you can drag the
slider to a percentage of your choice. (lesser the percentage, less
detailed the boundaries will appear. if you slide it to very low levels
make sure "prevent shape removal" option is ticked, otherwise you will lose
smaller org units during the process.

4. once done you should download the shape file that is generated. it will
have lesser detailed GIS data which will make a smaller .gml file

5. if you are on windows download FWTools (http://fwtools.maptools.org/).
You have to make sure the GIS cordinates of your shafiles are in  then in
EPSG:4326(WGS84 in arcgis), otherwise the final .gml file will have
misplaced orgunits. open console window and user ogr2ogr to generate .gml
file from shape file as follows

*ogr2ogr -f GML filename.gml filename.shp*

you may have to add additional parameters if your coordinates are not in
(EPSG:4326)

6. This will generate the .gml file. .gml file is an xml file it has
various tags representing attributes that came with shapefile and .dbf
file. you can open .gml file from notepad or notepad++.

7. then find the attribute data equivalent to  the data bearing org unit
name in your DHIS2 instance. following is a part of my .gml file


  <gml:featureMember>
    <ogr:sl_moh_gn_wgs84 fid="F575">
      <ogr:geometryProperty><gml:Polygon
srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>80.526509481818522,6.037236515074813
80.527137163010295,6.036849434859485 80.526354327120274,6.036559412410804
80.526509481818522,6.037236515074813</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
      <ogr:OBJECTID_1>576</ogr:OBJECTID_1>
      <ogr:PROVINCE_N>SOUTHERN</ogr:PROVINCE_N>
      <ogr:PROVINCE_C>3</ogr:PROVINCE_C>
      <ogr:DISTRICT_N>MATARA</ogr:DISTRICT_N>
      <ogr:DISTRICT_C>2</ogr:DISTRICT_C>
      <ogr:DSD_N>THIHAGODA</ogr:DSD_N>
      <ogr:DSD_C>36</ogr:DSD_C>
      <ogr:GND_NO>349A</ogr:GND_NO>
      <ogr:GND_N>Narangala</ogr:GND_N>
      <ogr:GND_C>090</ogr:GND_C>
      <ogr:MC_UC_PS_N>Thihagoda PS</ogr:MC_UC_PS_N>
      <ogr:AREA>1514070.7600000000</ogr:AREA>
      <ogr:ORIG_FID>0</ogr:ORIG_FID>
      <ogr:SHAPE_LENG>387.5145839710</ogr:SHAPE_LENG>
      <ogr:SHAPE_LE_1>387.5145839710</ogr:SHAPE_LE_1>
      <ogr:MOH_N>THIHAGODA</ogr:MOH_N>
      <ogr:OBJECTID>0</ogr:OBJECTID>
      <ogr:SHAPE_LE_2>0.0000000000</ogr:SHAPE_LE_2>
      <ogr:RDHS>MATARA</ogr:RDHS>
      <ogr:SHAPE_LE_3>387.5145621700</ogr:SHAPE_LE_3>
      <ogr:SHAPE_AREA>9244.0032229500</ogr:SHAPE_AREA>
    </ogr:sl_moh_gn_wgs84>
  </gml:featureMember>

In above example "GND_N" is the metadata holding my org unit name .. So you
need to find and replace all "GND_N" to "Name". following is the one after
replacement.

  <gml:featureMember>
    <ogr:sl_moh_gn_wgs84 fid="F575">
      <ogr:geometryProperty><gml:Polygon
srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>80.526509481818522,6.037236515074813
80.527137163010295,6.036849434859485 80.526354327120274,6.036559412410804
80.526509481818522,6.037236515074813</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
      <ogr:OBJECTID_1>576</ogr:OBJECTID_1>
      <ogr:PROVINCE_N>SOUTHERN</ogr:PROVINCE_N>
      <ogr:PROVINCE_C>3</ogr:PROVINCE_C>
      <ogr:DISTRICT_N>MATARA</ogr:DISTRICT_N>
      <ogr:DISTRICT_C>2</ogr:DISTRICT_C>
      <ogr:DSD_N>THIHAGODA</ogr:DSD_N>
      <ogr:DSD_C>36</ogr:DSD_C>
      <ogr:GND_NO>349A</ogr:GND_NO>
      <ogr:Name>Narangala</ogr:Name>
      <ogr:GND_C>090</ogr:GND_C>
      <ogr:MC_UC_PS_N>Thihagoda PS</ogr:MC_UC_PS_N>
      <ogr:AREA>1514070.7600000000</ogr:AREA>
      <ogr:ORIG_FID>0</ogr:ORIG_FID>
      <ogr:SHAPE_LENG>387.5145839710</ogr:SHAPE_LENG>
      <ogr:SHAPE_LE_1>387.5145839710</ogr:SHAPE_LE_1>
      <ogr:MOH_N>THIHAGODA</ogr:MOH_N>
      <ogr:OBJECTID>0</ogr:OBJECTID>
      <ogr:SHAPE_LE_2>0.0000000000</ogr:SHAPE_LE_2>
      <ogr:RDHS>MATARA</ogr:RDHS>
      <ogr:SHAPE_LE_3>387.5145621700</ogr:SHAPE_LE_3>
      <ogr:SHAPE_AREA>9244.0032229500</ogr:SHAPE_AREA>
    </ogr:sl_moh_gn_wgs84>
  </gml:featureMember>

8. Once done you will have the completed .gml file that you can import to
DHIS2. but better do a dry run first to exclude any org units that are
duplicates/ignored etc.

hope this helps.

Regards,
Pamod







On Fri, Apr 10, 2015 at 1:25 PM, Knut Staring <knutst@xxxxxxxxx> wrote:

> Hi Muhammad,
>
> Actually, the GML route is not strictly necessary, and quite cumbersome,
> as it involves a number of tools. I strongly suggest you rather work with
> Sushil Chitrakar (copied) and try his App which takes care of both properly
> formatting and importing shapefiles directly. Sushil can guide you through
> all the steps, and will also be grateful for any feedback on the App and
> the process.
>
> Regards,
> Knut
>
> On Fri, Apr 10, 2015 at 9:32 AM, Muhammad Bilal Siddqui <
> m.bilalsiddqui@xxxxxxxxxxxxxxx> wrote:
>
>> Can i get some GML file sample that can import in DHIS2. I want to make a
>> GML file for my country OUs but i dont know how to make one? Is GML file is
>> some .gml file like that or else?
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-users
>> Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-users
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>
>
> --
> Knut Staring
> Dept. of Informatics, University of Oslo
> Norway: +4791880522
> Skype: knutstar
> http://dhis2.org
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Pamod

References