Advertisement
Guest User

Untitled

a guest
Jan 31st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1.  
  2. # SQL Server
  3.  
  4. Create some simple tables in SQL Server for testing, no heterogeneous tables here, just ordinary point and line for now.
  5.  
  6. CREATE TABLE point_table (
  7.   shapeid int identity(1,1),
  8.   shapename varchar(32),
  9.   shapegeom geometry
  10. );
  11.  
  12. INSERT INTO point_table (shapename, shapegeom) VALUES
  13. ('Point #1', geometry::STGeomFromText('POINT(13 10)', 2199)),
  14. ('Point #2', geometry::STGeomFromText('POINT(7 12)', 2199))
  15. );
  16.  
  17. CREATE TABLE line_table (
  18.   shapeid int identity(1,1),
  19.   shapename varchar(32),
  20.   shapegeom geometry
  21. );
  22.  
  23. INSERT INTO line_table (shapename, shapegeom) VALUES
  24. ('Line #1', geometry::STGeomFromText('LINESTRING(13 10, 7 12)', 2199)),
  25. ('Line #2', geometry::STGeomFromText('LINESTRING(7 12, 5 5)', 2199))
  26. );
  27.  
  28. # OGR2OGR
  29.  
  30. cd C:\OSGeo4W64\bin
  31.  
  32. ogrinfo -al "MSSQL:Server=DESKTOP-E5J657H\SQLEXPRESS;Database=SpatialDB;Uid=rkhan;tables=line_table;trusted_connection=yes;"
  33.  
  34. ogr2ogr \
  35. -f "PostgreSQL" \
  36. -overwrite \
  37. "PG:host=127.0.0.1 user=postgres dbname=gis password=paresh1234" \
  38. "MSSQL:Server=DESKTOP-E5J657H\SQLEXPRESS;Database=SpatialDB;Uid=rkhan;trusted_connection=yes;" \
  39. -lco GEOMETRY_NAME=geom \
  40. -lco DIM=2 \
  41. -lco FID=pk \
  42. line_table
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement