Questions tagged [sql-server-spatial]
Microsoft SQL spatial database
149 questions
0
votes
0
answers
78
views
ogr2ogr exporting from MSSQL slow -- relatively
So when I pull the same stored procedure on my machine in SQL Server Management, we get 600+ megabits for about 100 seconds. Keep in mind this SQL Server has plenty of RAM, Cores, etc, and 20gig ...
1
vote
0
answers
164
views
Connecting QGIS to SQL server -- not showing sde
I have problem with seeing/making connection to spatial data on SQL Server with QGIS while I can normally see it (on the same SQL Server) with ArcMap.
I should use the same user and password for both ...
1
vote
1
answer
334
views
Unable to load data from a shapefile to SQL Server 2019 [closed]
Windows 10; GDAL 3.3.0; QGIS 3.2; Sql Server 2019; ODBC Driver 17 for SQL Server
When I try to load my shapefiles into my SQL Server no rows are loaded, only the table structure for each shapefile. I'...
0
votes
0
answers
991
views
Generate WKT from geometry type in SQL Server
I have a bunch of polygon data in a SQL Server database.
Most of the data was created in Google Earth and exported as KML, then imported to SQL Server as WKT before conversion to geometry.
Each record ...
2
votes
0
answers
252
views
Converting Geometry to a Geography yields an invalid shape SQL SERVER
I have two Geometry shapes of types Polygon or MultiPolygon [with Lat & Lng points] that I want to get their intersected shape.
I do this as follows:
land_shape.STIntersection(grid_shape) as shape
...
1
vote
0
answers
103
views
Combine lines and calculate their length in SQL Sever 2017 using spatial SQL [closed]
I have some geographic line[polyline] data in a table and I wish to merge based on a matching ID number. I then wish to measure the lengths of these combined lines and do all of this via an SQL query.
...
0
votes
1
answer
129
views
Layer from SQL Server fails when it contains WKT or area calculated from geometry
QGIS 3.28, MS SQL Server 2016, EPSG:25832
I'm trying to open a view from a MSSQL database. It works ok, until I include columns that contain the WKT expression of the geometry, or the area of polygons....
1
vote
0
answers
254
views
Issues saving and retrieving data from MS SQL Server with QGIS
Wondering if anyone has issues with geometry not loading into QGIS when sourced from MS SQL Server for following specific case.
Software specifics:
MS SQL Server spatial :15.0.2000.5 Standard Edition (...
1
vote
1
answer
105
views
Can't see SQL Server Spatial layers in GeoServer [closed]
I have a SQL Server Spatial database with a database called EDX. That database has a table called GEOMETRY_COLUMNS in its DBO schema. That table is populated with the spatial tables in the schema/...
0
votes
0
answers
106
views
Inconsistent results from spatial databases
I'm trying to write something agnostic to whichever database vendor is chosen between MySQL, SQL Server, Oracle, and PostgreSQL. However, I see inconsistent results in functions that return measures. ...
1
vote
2
answers
2k
views
Attempting to use ogr2ogr to convert shapefile to SQL Server table; getting error "unable to find driver mssqlspatial"
I have shapefiles with geographic data (polygon geometry only) that I'd like to import into tables in a SQL Server instance over which I have no direct control (but I'm working closely with someone ...
0
votes
0
answers
103
views
Join to MSSQL table with no geom
I'm using QGIS 3.22.5. I want to join an MS SQL Server (MSSQL) spatial table to an MSSQL non-spatial table. I don't see that I can do this. Am I missing something? Can someone tell me how to add a ...
0
votes
0
answers
123
views
OGR SQL Empty Output
I have a Powershell script that loops through a database and outputs the spatial tables into another database in GDA2020 datum. I see one particular table is outputting but is empty. This table should ...
1
vote
1
answer
286
views
Does QGIS import SQL Server data or query it?
I have a SQL Server DB with about 200GB of various datapoints stored on server.
When I use this datasource in QGIS from my PC would all the data be imported?
I.e do I need to make sure I have 200GB ...
5
votes
1
answer
228
views
MSSQL STIntersection Results in COMException
Using MS SQL Server 2019 and running the following query results in the COMException displayed below.
DECLARE @Geom1 AS GEOMETRY
DECLARE @Geom2 AS GEOMETRY
SET @Geom1 = ...
1
vote
2
answers
432
views
Combine different geometry types in single layer in MapServer- is it possible?
I'm trying to display features with different geometry types in single LAYER. MapServer version 7.0.1 (MS4W 3.1.4). The data source is MS SQL spatial database table with geometry column, containing ...
0
votes
1
answer
175
views
Create a Clone of existing Spatial DB on SQL Server instance
I have a spatial database on a SQL Server Instance. I want to create a copy of it in the same instance. I tried the following approaches:
Backing up the existing XYZ DB and restoring it with a new ...
1
vote
1
answer
1k
views
STContains, STIntersects and STWithin return wrong result for geography loaded from WKT
I'm trying to determin whether a point is within a polygon. I created a polygon a two points with this tool: https://clydedacruz.github.io/openstreetmap-wkt-playground/
Polygon:
POLYGON((18....
6
votes
2
answers
2k
views
Speed difference MS SQL Server 2019 to PostgreSQL/PostGIS 12 for spatial data
I imported a shapefile with 3000 polygons in UTM 25832 into both databases MS SQL Server 2019 and PostgreSQL/PostGIS. Then I calculated a buffer of 1000 meters around these geometries and transferred ...
1
vote
0
answers
308
views
Loading geometry point tables in SQL Server Spatial
I need to load point data in SQL Server Spatial.
Similar to this post but I really don't know how to get XY data to be accessible by SQL
I want to do what was done in the initial part of this post (...
0
votes
0
answers
254
views
Convert a SQL Server table to a shapefile with projection info
I've been using ogr2ogr to write out shapefiles from my SQL Server spatial map layers. When I run the command it delivers the .shp, .shx, and the .dbf but no prj file. Is there a way to get ogr2ogr ...
1
vote
0
answers
341
views
Converting non-simple geometries to simple so ArcGIS Pro can display and process them
In SQL Server 2016 I'm using GEOMETRY::UnionAggregate to dissolve some polygons into larger ones. Here is a simplified example of my select:
select ta.TRANUM, GEOMETRY::UnionAggregate(pp.SHAPE) SHAPE ...
2
votes
1
answer
205
views
Can not load spatial data from MSSQL on Linux
I have a table on the MS SQL server. I am trying to import the data in R using the rgdal package. I can import the table on Windows without any problems using the following code:
readOGR(dsn = "...
1
vote
0
answers
308
views
How to calculate a line from a position and bearing in SQL Server 2012 (Spatial)
Currently I've a table filled with measurements from a certain point. All the rows contain a location in Lat/Lon, a bearing in degrees and some other data containing sensor updates etc. At this moment ...
0
votes
0
answers
252
views
Warning 6 while loading data to MSSQLSpatial using ogr2ogr
I am loading layers from a .gdb to a database in SQL Server using the following command:
ogr2ogr -f MSSQLSpatial "MSSQL:server=server_name;database=database_name;trusted_connection=yes" &...
0
votes
1
answer
321
views
Unable to connect to SQL Server tables with 10.5 ArcMap but it works with 10.7
I have a requirement where I need to connect to the SQL Server which I have created using ArcCatalog 10.7.
I have a requirement where I need to now use 10.5 version. But when I attempt to connect to ...
1
vote
1
answer
279
views
SQL Server Spatial Enable Spatial column and Analysis
I have:
a table called ABC with columns (ID, County_Name, Lat, Long) in SQL
server pre-filled with the values under its respective columns,
except for County_Name column which is currently null.
an ...
2
votes
1
answer
1k
views
Can't convert a WKT with a Z value into a SQL Geometry value
I'm using nettopologysuite in c# to build a nettopology geometry object, and then save it as a geometry object in SQL. Generally this works fine, except i recent came up with (from a shapefile) the ...
4
votes
2
answers
3k
views
Combining ST Buffer and Intersect with Where clause
I'm trying to create a buffer around a single point in a spatial entity and finding all the points from a different entity that fall within that buffer.
I tried two approaches. The code below runs ...
2
votes
2
answers
3k
views
Running ogr2ogr in Python on Windows
I run ogr2ogr to transfer geometrical data from a pgsql (PostGIS) database to a MS SQL one. It works quite well. I'm trying to achieve exactly the same result in Python, as I'm planning to use ...
0
votes
1
answer
234
views
Loaded vector layers from SQL Server 2014 but data is not visible on the map in QGiS 3.8.3 - Zanzibar
This is odd - I've successfully connected to my spatial sql server 2014 instance, and loaded two point layers and one Polygon layer into QGIS. I see nothing on the map. I zoom to the layer, I know ...
1
vote
1
answer
259
views
ogr2ogr MSSQLSpatial truncating attribute fields
I have a Shapefile with a number of attribute fields defined in its corresponding .dbf file. I am trying to transfer this data to an Azure SQL Server DB using the following command:
ogr2ogr -f ...
0
votes
0
answers
112
views
Possible to import current version (v2) of the SQL Server Spatial binary format with QGIS/GDAL?
I'm running QGIS 3.4.3 on a Windows 10 machine and when loading vector layers from our MS SQL Server version 12 everything seems to be working great. No problems connecting or visualizing the data. ...
1
vote
0
answers
274
views
Similarity between two sets of lat/long points
I am trying to measure the similarity between two trajectories (two sets of lat/long points) which are the outputs from two APIs. I am trying to measure the difference between the routes given by ...
1
vote
1
answer
370
views
Polygon node order will not correct [duplicate]
I've got a few polygons (they were previously one multipolygon) which seem to insist on having an anticlockwise node order. As such, when running through various operations in SQL, they throw out the ...
2
votes
1
answer
361
views
QGIS with MSSQLSpatial : no geometry. OgrInfo Corrupt data
I am having this issue while I am trying to connect to my MSSQLSpatial database.
So, I've created this features with just one record with geometry. I can see this feature on Microsoft Management ...
1
vote
0
answers
58
views
QGIS 3.45 Layers Panel point data labels set too far apart
The Layers Panel in v 2.18 is fine but we are now trying to go live with 3.45 and are experiencing issues with the display of some layers in the panel.
Layers that are generated from an MSSQL spatial ...
1
vote
1
answer
882
views
Extract intersecting polygon from multipolygon search
I'm using the latest SQL Server and trying to build a query where i can search a database of spatial data and find the intersecting polygon.
The problem is that the spatial data can be of ...
2
votes
1
answer
328
views
ogr2ogr with GDAL 2.4 not reprojecting correctly
I have downloaded the latest OSGeo4w (GDAL 2.4) and GDAL 2.4 (from GIS Internals site) but I cant get the below command to correctly reproject the shapes in either application.
I used the command ...
1
vote
0
answers
565
views
Connect to MSSQL from QGIS on Mac
I tried to connect to MSSQL from QGIS and I couldn't find any solution to my problem.
I install MSSQL on my Mac with Docker and try to connect QGIS with localhost(host=localhost) and left the DSN ...
3
votes
1
answer
251
views
Can QGIS use MS SQL Server 2016
Does anyone know if there are any issues for QGIS in accessing MS SQL Server 2016?
I am currently using 2008, but there are a number of new functions within 2016 that are attractive for the upgrade.
0
votes
0
answers
82
views
Connect Mapnik to MSSQL
I want to connect Mapnik to MSSQL Spatial SDE, but I don't know how to do this.
import mapnik
m = mapnik.Map(256,256)
mapnik.load_map(m, "test.xml")
m.zoom_all()
mapnik.render_to_file(m, "2.png")
...
1
vote
0
answers
81
views
How to deal with decimal separator when uploading geometries to MSSQL server using shape2sql.exe?
I'm using Shape2Sql.exe to upload .shp shapefile to MSSQL server 13.0.4502.0 on a Win10 64bit laptop. I've added Shape2Sql.exe.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>...
0
votes
0
answers
588
views
MS SQL Server STEnvelope() performance
Using MS SQL Server 2012, when we write a query with
select GEOM.STEnvelope() from table
where table holds approx. 4000 native SQL Server line geometries of type geometry, with 2/6/180 points min/...
6
votes
1
answer
888
views
Using new Australian Datum GDA2020 in SQL Server 2016?
We have several hundred datasets/spatial layers within SQL Server 2016 which has the geometry datum/projection of GDA1994 Zone 54 (EPSG:28354) and we wish to reproject/shift the spatial locations to ...
2
votes
0
answers
957
views
Importing SHP to MSSQL using OGR2OGR?
I am trying to import a Shapefile which is in EPSG:4326 coordinates to MSSQL Database but its failing. I am following the below command:
ogr2ogr -f MSSQLSpatial -overwrite "MSSQL:server=...
1
vote
0
answers
677
views
Parsing Geometry to Latitude, Longitude is failing
I have a table 'geocodes_raw' of locations with Latitude and Longitude values.
Loc_Nm || geocode_latitude || geocode_longitude
A || 43.43044 || -80.0910793
W || 43.9114523 ...
1
vote
1
answer
1k
views
Pulling Spatial Data in Geography Format From MS SQL Server 2008 Using ogr2ogr
Can the MSSQLSpatial driver support geography fields queried from MS SQL Server 2008 as spatial data?
Background
I have been using unixODBC on an Ubuntu 16.04 machine with ODBC Driver 17 for SQL ...
3
votes
1
answer
2k
views
SQL WKT draws well with geometry, but not with geography data type
I have a following piece of code
DECLARE @g geometry;
DECLARE @borders geography;
SET @g = geometry::STGeomFromText('SOME WKT', 0);
SET @borders = GEOGRAPHY::STGeomFromText(@g.MakeValid()....
2
votes
2
answers
2k
views
Query MSSQL geography data type against a bounding box
I'm currently storing geographic locations as data type geography in my MSSQL database and performing radius queries against it without issue.
Is it possible to query against it using a polygon ...