TransWikia.com

Identify EPSG in SQL Server

Geographic Information Systems Asked by ravsun on January 14, 2021

I have been trying to load a shapefile available at https://www.elections.on.ca/en/voting-in-ontario/electoral-district-shapefiles/open-use-data-product-licence-agreement/download-shapefiles.html to SQL Server 2014 in the EPSG: 4326 formats.

I tried this using the Shape2SQL tool available at https://www.sharpgis.net/page/SQL-Server-2008-Spatial-Tools

I checked the “Planar Geometry” option and left the “Set SRID” field unchecked. If I check the “Set SRID” field and enter 4326 in the field, nothing gets uploaded to SQL Server. Hence, I left it unchecked.

The loaded coordinates look like this and are NOT in LAT LONG form:

ID  ED_ID ENGLISH_NA       FRENCH_NAM       SHAPE_area    SHAPE_len  geom
1   8     Brampton Centre  Brampton-Centre  4.444118E+07  32761.97   0x000000000104B6010000A...

After uploading to the database, when I checked the SRID for the imported table in SQL Server using the command:

select distinct SP_GEOMETRY.STSrid from dbo.MYTABLE

It returns “0”.

Please help with following questions:

  1. Is the shapefile getting loaded into the SQLServer correctly?

  2. How do I convert the loaded data to EPSG: 4326?

One Answer

You can use the following:

UPDATE MYTABLE SET SP_GEOMETRY.STSrd = '4326'

To check it worked, first use SQL to verify the values were written correctly:

SELECT SP_GEOMETRY.STSrid from MYTABLE

(don't use distinct)

You might also ensure the coordinates are in WGS84 by selecting the geometry as text:

SELECT SP_GEOMETRY.STAsText()

Then, can you add the data to QGIS to ensure it draws correctly?

Answered by DPSSpatial on January 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP