Last active
September 4, 2015 10:14
-
-
Save neogis-de/6fcca708020dda4a5fca to your computer and use it in GitHub Desktop.
ogr2ogr merge Ordnance Survey shapefiles from different subfolders together
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set OSGEO4W_ROOT=C:\OSGeo4W64 | |
call "%OSGEO4W_ROOT%\bin\o4w_env.bat" | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
rem set your folder which contains the shapefiles and change to this folder: | |
set verzeichnis=C:\YourShapefileFolder\ | |
cd %verzeichnis% | |
rem recursive for loop | |
FOR /R %%b IN (*.shp) DO ( | |
rem get filename without path | |
set var=%%~nxb | |
rem cut off the first three characters | |
echo merging now: !var! to !var:~3! | |
rem merge the files together | |
if NOT exist "!var:~3!" (ogr2ogr -f "ESRI Shapefile" "!var:~3!" "%%~fnxb") else (ogr2ogr -append -update -f "Esri Shapefile" "!var:~3!" "%%~fb" ) | |
) | |
Echo ------------------------------------- | |
Echo merging done! | |
Echo ------------------------------------- | |
PAUSE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment