Skip to content

A Postgres/PostGIS dump of FeatureCollections for the African continent. Useful for those instances where you have to fire up a Postgres/PostGIS instance for use with libraries such as Leaflet but do not have sufficient time to generate the required set or install tools (e.g. QGIS) for the purpose

Notifications You must be signed in to change notification settings

michaelchamu/africa-geojson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

africa-geojson

Africa-geojson is a SQL script to enable you to create a database table in PostGres with African Continent GeoJSON data.

Set Up

You need access to a PostGresql database instance. Download the file and run the following command in the terminal:

psql -U [database-username] countries < africa.geojson.sql

Usage

The resulting table can be queried to obtain a geojson set that can be used in libraries such as leaflet.js. The following is an example query to retrieve the GeoJson data for a specific country using the country name:

SELECT ST_AsGeoJSON(ST_Transform((geom),4326),6) AS geojson FROM countries where admin like 'Zimbabwe'

The query returns the following result:

{"type":"Polygon","coordinates":[[[31.287891,-22.402051],[31.197266,-22.344922],[31.073438,-22.307813],[30.916113,-22.290723],[30.711621,-22.297852],[30.460156,-22.329004],[30.19043,-22.291113],[29.902344,-22.18418],[29.663086,-22.146289],[29.377441,-22.192773],[29.364844,-22.193945],[29.315234,-22.157715],[29.237207,-22.079492],[29.106836,-22.065723],[29.071484,-22.047461],[29.042383,-22.018359],[29.02334,-21.98125],[29.01582,-21.939941],[29.037305,-21.811328],[29.025586,-21.796875],[28.990723,-21.781445],[28.919336,-21.766016],[28.747754,-21.707617],[28.532031,-21.65127],[28.181641,-21.589355],[28.045605,-21.573047],[28.014063,-21.554199],[27.974609,-21.506738],[27.907422,-21.359082],[27.844141,-21.261523],[27.693457,-21.111035],[27.669434,-21.064258],[27.676953,-20.944824],[27.688086,-20.84834],[27.704297,-20.766406],[27.696973,-20.689746],[27.694824,-20.594531],[27.699609,-20.530664],[27.679297,-20.503027],[27.624609,-20.483594],[27.468945,-20.474805],[27.280762,-20.478711],[27.274609,-20.381836],[27.256738,-20.232031],[27.221484,-20.145801],[27.178223,-20.100977],[27.091797,-20.054199],[26.916699,-19.990137],[26.678223,-19.892773],[26.474609,-19.748633],[26.241016,-19.569336],[26.168066,-19.538281],[26.081934,-19.369922],[25.950684,-19.081738],[25.95918,-18.985645],[25.939355,-18.938672],[25.811914,-18.79707],[25.783691,-18.723535],[25.76123,-18.649219],[25.558301,-18.441797],[25.489258,-18.35127],[25.436719,-18.234961],[25.384375,-18.141992],[25.340234,-18.104492],[25.282422,-18.041211],[25.242285,-17.969043],[25.224023,-17.915234],[25.239063,-17.843066],[25.258789,-17.793555],[25.451758,-17.845117],[25.557129,-17.849512],[25.639648,-17.824121],[25.741602,-17.858203],[25.863281,-17.951953],[25.995898,-17.969824],[26.139551,-17.911719],[26.333398,-17.929297],[26.577539,-18.022559],[26.779883,-18.041504],[27.020801,-17.958398],[27.235742,-17.72832],[27.437891,-17.511914],[27.636719,-17.262109],[27.756543,-17.060352],[27.932227,-16.896191],[28.16377,-16.769727],[28.399805,-16.662793],[28.760645,-16.531934],[28.760547,-16.532129],[28.832715,-16.424121],[28.856738,-16.306152],[28.856738,-16.142285],[28.875586,-16.036133],[28.913086,-15.987793],[28.973047,-15.950098],[29.050586,-15.901172],[29.287891,-15.776465],[29.487305,-15.696777],[29.72959,-15.644629],[29.994922,-15.644043],[30.250684,-15.643457],[30.396094,-15.643066],[30.398145,-15.800781],[30.409375,-15.978223],[30.437793,-15.995313],[30.630176,-15.999219],[30.93877,-16.011719],[31.23623,-16.023633],[31.426172,-16.152344],[31.489844,-16.179688],[31.687598,-16.21416],[31.939844,-16.428809],[32.243262,-16.44873],[32.451953,-16.515723],[32.63584,-16.589453],[32.741797,-16.677637],[32.810254,-16.697656],[32.90293,-16.704199],[32.948047,-16.712305],[32.937891,-16.775977],[32.87627,-16.883594],[32.884375,-17.037793],[32.969336,-17.251562],[32.980762,-17.4375],[32.954687,-17.76543],[32.955566,-18.08291],[32.964648,-18.196289],[32.978516,-18.271484],[32.996387,-18.312598],[32.993066,-18.35957],[32.94248,-18.492676],[32.90166,-18.63291],[32.900293,-18.689062],[32.88457,-18.728516],[32.854492,-18.763672],[32.721973,-18.828418],[32.699219,-18.868457],[32.699707,-18.940918],[32.716504,-19.001855],[32.766211,-19.024316],[32.826172,-19.058789],[32.849805,-19.104395],[32.85,-19.152441],[32.830957,-19.241406],[32.777637,-19.38877],[32.830762,-19.558203],[32.89043,-19.668066],[32.972656,-19.79541],[33.006738,-19.873828],[33.004883,-19.930176],[32.992773,-19.984863],[32.869629,-20.217188],[32.780859,-20.361523],[32.672559,-20.516113],[32.529297,-20.613086],[32.492383,-20.659766],[32.477637,-20.712988],[32.482813,-20.828906],[32.476172,-20.950098],[32.353613,-21.136523],[32.429785,-21.29707],[32.412402,-21.311816],[32.371094,-21.334863],[32.194727,-21.51543],[32.016309,-21.698047],[31.885938,-21.831543],[31.737695,-21.983398],[31.571484,-22.153516],[31.429492,-22.298828],[31.287891,-22.402051]]]}

About

A Postgres/PostGIS dump of FeatureCollections for the African continent. Useful for those instances where you have to fire up a Postgres/PostGIS instance for use with libraries such as Leaflet but do not have sufficient time to generate the required set or install tools (e.g. QGIS) for the purpose

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages