[Qgis-user] No geometry for sql server

Christophe B ampouillle at gmail.com
Thu Jun 9 03:22:31 EDT 2011


Hello Nathan,

thanks for your last blog post
<http://woostuff.wordpress.com/2011/06/07/opening-ms-sql-server-2008-spatial-tables-in-qgis-correctly/>on
MSSQL.
Just a little question : ogr2ogr create a geometry type with -overwrite
control
It is possible to use the geography GEOM_TYPE ? (all my tables are in geography
type)

On OSGeo4w shell :
ogr2ogr -overwrite -f MSSQLSpatial "MSSQL:server=server;database=
basename;trusted_connection=yes;GeometryFormat=wkb" "C:\Shape\temp.shp" -lco
SRID=4326 -lco GEOM_TYPE=GEOGRAPHY

return :
ERROR 1: INSERT command for new feature failed. [Microsoft][ODBC SQL Server
Driv
er][SQL Server]A .NET Framework error occurred during execution of
user-defined
routine or aggregate "geography":
System.FormatException: 24204: The spatial reference identifier (SRID) is
not va
lid. The specified SRID must match one of the supported SRIDs displayed in
the s
ys.spatial_reference_systems catalog view.

yet, there is [4326    EPSG    4326    GEOGCS["WGS 84",...] on the
sys.spatial_reference_systems

Have you encountered the same problem ?


2011/4/13 Nathan Woodrow <madmanwoo at gmail.com>

> The issue is not with the python code itself but rather something in the
> qgis code for the ogr provider.  I know there is a bug there I'm just having
> trouble tracking down what it is.
>
>
> On Wed, Apr 13, 2011 at 6:07 PM, Yves Jacolin <yjacolin at free.fr> wrote:
>
>> Christophe,
>>
>> Why do you say the issue come from the python code? Your example shows
>> nothing
>> ;)
>>
>> What is the result of your last command?
>>
>> Y.
>> Le mercredi 13 avril 2011 09:49:04, Christophe B a écrit :
>> > Hello Yves,
>> >
>> > I tried to convert my table to a shapfile with ogr2ogr (GDAL 1.8.0,
>> > released 2011/01/02) and it works : my shapfile has geometry and
>> attribute
>> > data. It is therefore a problem whis python code !
>> >
>> > >>> conn_string ="MSSQL:server=.\SQLEXPRESS;
>> >
>> >
>> database=ObservatoireCommerce;tables=dbo.T_CommuneGeographie;trusted_connec
>> > tion=yes"
>> >
>> > >>> qgis.utils.iface.addVectorLayer(conn_string,'test','ogr')
>> >
>> > 2011/4/12 Yves Jacolin <yjacolin at free.fr>
>> >
>> > > Christophe,
>> > >
>> > > could you test ogr directly to connect to your SQL Server? For example
>> > > convert
>> > > sql server layer into shapefile. You will know if this is an ogr or
>> QGIS
>> > > issue.
>> > >
>> > > Y.
>> > >
>> > > Le mardi 12 avril 2011 12:39:21, Nathan Woodrow a écrit :
>> > > > This seems to be a bug, I have noticed it is happens mainly on
>>  Windows
>> > >
>> > > XP
>> > >
>> > > > but Windows 7 also has this bug.  I'm not sure where the problem is,
>> I
>> > > > suspect QGIS as OGR via command line returns the correct objects.
>> > > >
>> > > > - Nathan
>> > > >
>> > > > On Tue, Apr 12, 2011 at 8:16 PM, Christophe B <ampouillle at gmail.com
>> >
>> > >
>> > > wrote:
>> > > > > Hello List,
>> > > > >
>> > > > > I now test the ability to connect to SQL Server data whis GDAL 1.8
>> of
>> > > > > QGIS 1.7.
>> > > > > The connection is correct but I have no geometry in return, and
>> the
>> > >
>> > > right
>> > >
>> > > > > attribute data (error).
>> > > > > Is a problem in GDAL / OGR? or QGIS 1.7?
>> > > > >
>> > > > > Should we open a new ticket ?
>> > > > >
>> > > > > Thank you in advance
>> > > > >
>> > > > > Christophe Baume
>> > > > >
>> > > > > _______________________________________________
>> > > > > Qgis-user mailing list
>> > > > > Qgis-user at lists.osgeo.org
>> > > > > http://lists.osgeo.org/mailman/listinfo/qgis-user
>> > >
>> > > --
>> > > Yves Jacolin
>> > >
>> > > http://yjacolin.gloobe.org
>>
>> --
>> Yves Jacolin
>>
>> http://yjacolin.gloobe.org
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-user/attachments/20110609/d2041f70/attachment.html


More information about the Qgis-user mailing list