Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'd like to hit a Geoservices REST endpoint (below) to return json and push this into a SQL Server Geometry table using Python.

Ok so I can achieve this via ogr using below via command line:

ogr2ogr -overwrite -nln "LCCGIS.CAD_Parcels_JSON" -f "MSSQLSpatial" "MSSQL:s erver=SQL2008P1\MSSQLSERVER32BIT;database=GISTEST;Uid=lccgis;pwd=password" "json" -lco "GEOM_NAME=Shape" -lco "SRID=28355" -lco "DIM=2"

Can someone help with how I do this using python bindings for GDAL or point me to a forum etc?...

table_driver = ogr.GetDriverByName( 'MSSQLSpatial' )

table_ds = shp_driver.CreateDataSource( "MSSQL:server=SQL2008P1\MSSQLSERVER32BIT;database=GISTEST;Uid=lccgis;pwd=password")

out_layer_name = "LCC.CAD_Parcels_JSON"

lco = ["GEOM_NAME=Shape","DIM=2"]

table_layer = shp_ds.CreateLayer( out_layer_name, geom_type = in_defn.GetGeomType(), srs = in_layer.GetSpatialRef(), options = lco )

geom_type and srs seem ok so I suspect options is the culprit.

My table_layer ends up being a NoneType

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.