spatial - Creating Shape Files from SQL Server using Ogr2ogr -
I am trying to run the following code in a command window. Executes the code, but does not give me any value in the SHP files. The geography type in the table is collections and polygons stored in the field of geography. I have made several changes for the geography type in the SQL statement - binary, text etc. But there is no luck. The output is in the .dbf file, so the connection to the database works, but the size. There is no data in the SHP file and .shx file and the size is of 17K and 11, respectively.
Choose a suggestion
ogr2ogr -f "ESRI shape" -overwrite c: \ Temp -nln Zip_States -sql "select [id2], [STATEFP10], [ZCTA5CE10 ], Geometry :: STGeomFromWKB ([Geography] .STAsBinary (), 4326) .STAsText () [geography] [geo-local] [dbo] from [us_State_Illinois_2010] "ODBC: .. Dbo / geo-spatial @ PPDULCL708504 Secondly, you are currently returning to the spatial area as a text string using STAsText (), but you are not telling OGR that it is a spatial area, so maybe it only Treating with a WKT as a regular text column and adding it as a feature in the DBF file. To tell OGR, if you have spatial information in the column, you can add the "Tables" parameter to the connection string. However, there is no reason to cast all the WKT / WKBs if you are using SQL Server 2008 - OGR2OGR will fix the original binary format of SQL Server
Do you really want SQL Server 2008, Or using Denali? Because the ordering format has changed, and OGR2OGR can not read the new format. So, in that case it is the first safe (but slow) to convert WKB
I do the following to dump a table of polygon from the SQL server to the shell:.
ogr2ogr -. Select "ESRI Size" -overwrite c: \ Temp -nln Zip_States -sql "Select ID, geom26986.STAsBinary () from [local] [dbo] [OUTLINE25K_POLY] .." "MSSQL: server = \ DENALICTP3; database = spatial; trusted_connection = yes; table = dbo.OUTLINE25K_POLY (geom26986)"
Comments
Post a Comment