← Back to team overview

dhis2-devs team mailing list archive

Re: Generating GeoJSON from the database

 

Working on converting all our data to geojson, I've changed my mind
for representation in the database somewhat. Instead of just having
the coordinates in one field and the type of geometry in another, it
will be both more efficient and easier to have just store the full
geometry string in one field, like this:

{"type": "Point", "coordinates": [6.18218, 45.5949]}

Similarly for Polygon and Multipolygon.

The problem we are encountering is that even with datatype text (in
Postgresql), the multipolygon strings sometimes are too long for the
field - not sure why that happens since text is defined as unlimited?
Our solution has been to both generalize (simplify) and limit
coordinates to two decimals, but it is still somewhat problematic
(these gemetries come from the PostGIS geometry format which works
well)

You can see how the above JSON snippet fits into the fully generated
GeoJSON file below:

{"type": "FeatureCollection", "features": [{"geometry":
{"type": "Point", "coordinates": [6.18218, 45.5949]}, "type":
"Feature", "properties": {"name": "Col d'Arclusaz"}, "id": 472},
{"geometry": {"type": "Point", "coordinates": [6.27827, 45.6769]},
"type": "Feature", "properties": {"name": "Pointe de C\u00f4te
Favre"}, "id": 458}

On Thu, May 20, 2010 at 9:13 AM, Knut Staring <knutst@xxxxxxxxx> wrote:
> Hi,
>
> Please find attached some PHP code I used to connect to a Mysql
> version of the DHIS2 db and produce GeoJSON.
>
> Would be great if we could have a service in DHIS 2 produce the same.
> Especially because this would allow us to easily create maps (map
> views) for just one district or province, and not the whole country,
> as many local users would want (though we may need some more machinery
> for the display of overlays in that case). This means that. a map view
> should be attached to an orgunit.
>
> Knut
>



-- 
Cheers,
Knut Staring



Follow ups

References