NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi,

I need to merge 2 huge shapefiles (~3.4GB each). I was using QGIS explorer to merge 2 shapefiles but the application runs out of memory and getting error can't exceed 4 GB shapefile limit . I want the same way QGIS merges vectors but using commandline tool so that I can merge them on the cloud server.

I tried merging 2 separate .osm files but there is some issue in osrm-extraction.

What is the proper way to merge 2 shape files?

asked 13 Feb '21, 09:36

Mukul2990's gravatar image

Mukul2990
11223
accept rate: 0%


You cannot merge two 3.4 GB shape files. Shape files have a size limit of 2 GB, and some applications like GDAL will allow you to create up to 4 GB (using unsigned IDs internally) but will warn you that these files might not be readable with other software. More than 4 GB isn't possible with any software.

Depending on what you want to do, you might want to switch to SQLite files which can be readily processed with GDAL (ogr2ogr command line tool). You can convert the first shape file to SQLite and then append the second shape file to that existing SQLite file. QGIS can load SQLite files.

Note that this simply combines the file into one. If by "merge" you mean an actual merge operation on geometries, combining overlapping features into one, then that's a different ballgame that would require loading the data into PostGIS.

permanent link

answered 13 Feb '21, 11:31

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

edited 13 Feb '21, 11:32

I was appending both shapefiles data to the table using this command to insert shapefile to PostGIS DB.

ogr2ogr -update -append -progress -f "ESRI Shapefile" PG:"dbname=postgres user=postgres port=5432 password=postgres" Shape1.shp -nln ShapeFilesData

But there were some issues with this approach. OSRM cluster was not showing the routes correctly.

(14 Feb '21, 05:35) Mukul2990

OSRM does not read shape files OR PostGIS database tables. If you want to do routing on PostGIS database tables, try PGRouting.

(14 Feb '21, 11:37) Frederik Ramm ♦

No. What I mean to say is I was using the shapefile data loaded in QGIS and generate .osm files, then that osm will generate .pbf which is supplied to the osrm-extraction.

(14 Feb '21, 21:43) Mukul2990

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×85

question asked: 13 Feb '21, 09:36

question was seen: 1,298 times

last updated: 14 Feb '21, 21:43

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum