1

I have a shapefile with countries, which I convert to GeoJSON using ogr2ogr and then converting that json to another TopoJSON, using topojson command-line tool.

Everything works like charm, but now I want to learn to concatenate/merge/join/cluster (just don't know what is the most appropriate term in GIS context) different neighbor shapes to a bigger ones - say, all African countries to one big Africa shape. Let's assume that all Hdata needed (like continent name) is present in the original shapefile.

So, what is the simplest way to merge neighbour shapes while converting shapefile to topojson format?

Sorry if this question is about something trivial, it's just that this is a new topic to me, though I'm very glad I should deal with such issues.

2 Answers 2

2

You can dissolve the neighbour shapes uniting their geometries grouped by country name while converting the shapefile to json with GDAL >= 1.10 with SQLite and SpatiaLite support:

ogr2ogr -f GeoJSON -dialect SQLite -sql "SELECT cont_name, ST_Union(geometry) FROM African_Countries GROUP BY cont_name" Africa.json African_Countries.shp
0

Better late than never. You think you'll need to merge/dissolve polygons separately with OGR2OGR (or a GIS or programming language like R) and then perform the conversion. I suspect it'll be difficult/impossible to perform both at the same time (but I look forward to being proved wrong).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.