TransWikia.com

Splitting shapefile into separate files within Meridians using QGIS

Geographic Information Systems Asked on April 11, 2021

Given a .shp that covers the globe, how could QGIS be used to segment that into 90 .shp files, each file containing lines/points/polygons/multipolygons that are between the first and second then second and third then third and fourth, etc?

Issue is a series of gigantic source files with global coverage that have no common attributes that would allow them to be conventionally partitioned. Since the source files have a relatively even distribution (not over the Pacific ocean of course), cutting them up into smaller files will make them cleaner to process.

I was hoping there was a hidden command in ogr2ogr that would do this, but I don’t see one.

One Answer

You can use the -spat option of ogr2ogr and a loop to do this. On a linux box I'd do something like:

for x in `seq -180 10 170`; do
     x2=$((x+10))
     ogr2ogr -spat $x -90 $x2 90 -spat_srs epsg:4326 outfile_$x.json infile.shp
done

Answered by Ian Turton on April 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP