Topic: Error in Spatial caculations
Recorder 6 does not calculate spatial co-ordinates correctly using the inbuilt SQL functions.
The problem I was trying to solve was to display all the Locations that have the same specified parent Location in QGIS. Within SQL Server 2014 Management Studio I created a table with the fields of
CREATE TABLE [dbo].[Location_Geometry](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Location_Key] [char](16) NOT NULL,
[GEOMTYPE] [nchar](10) NULL,
[GEOM] [geometry] NULL,
PRIMARY KEY CLUSTERED (....
I then populated the table using the command
INSERT INTO [dbo].[Location_Geometry]
([Location_Key],
[GEOMTYPE],
[GEOM])
SELECT LOC.[LOCATION_KEY], 'point',
[dbo].[LCSpatial_OSGB_Geom](LOC.[SPATIAL_REF], LOC.[SPATIAL_REF_SYSTEM],1)
FROM [NBNData].[dbo].[LOCATION] AS LOC
This uses the function as documented in this post http://forums.nbn.org.uk/viewtopic.php?pid=17111#p17111
Which in turn calls functions supplied by Recorder 6
The tables
LOCATION
LOCATION_NAME
Location_Geometry - (the table created above)
Where joined and the results plotted after suitable filtering. The filter selected the correct number of rows. However, not all the results were plotted. On further investigation it was found that four sites close together were being plotted as one site at the location of Chiddingfold Forest West, but being named as Chiddingfold Forest East. The other three sites not being plotted.
Attached is an extract of the four sites showing their spatial references.
If it helps, I have SQL code that correctly calculates the geometry for any OSGB grid reference which works for PostgreSQL, so will probably need some modification to work correctly in MS SQL Server.
Surrey County Butterfly Recorder