Last active
August 29, 2015 14:16
-
-
Save NathanW2/691207123db6750890eb to your computer and use it in GitHub Desktop.
Import file to SQL Sever using OGR2OGR (drag and drop file onto batch file to import that file)
This file contains 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
REM Drag and drop OGR2OGR file for importing a layer into the database | |
REM Drop a file that OGR supports to kick off import | |
@ECHO OFF | |
SET dbserver=localhost\SQLEXPRESS | |
SET dbname=Test | |
SET db="MSSQL:server=%dbserver%;database=%dbname%;trusted_connection=yes" | |
SET ARGS=-s_src EPSG:28356 -progress -overwrite -lco GEOM_NAME:SP_GEOMETRY | |
SET OSGEO4W_ROOT=C:\OSGeo4W\ | |
CALL %OSGEO4W_ROOT%bin\o4w_env.bat | |
ECHO Uploading %nln% ... | |
SET TABLENAME=%~n1 | |
SET /p TABLENAME="New name for layer (default %TABLENAME%):" | |
ogr2ogr -f MSSQLSpatial %ARGS% %db% %1 -nln %TABLENAME% | |
ogrinfo -sql "create spatial index on %TABLENAME%" %db% | |
ECHO Uploaded %TABLENAME% to %dbname% | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment