2

I have a 3 GB database in SQL Server, with certain points stored in float values. The points are stored in EPSG 3765. I would prefer to have them saved in the Geography datatype. I can not store them directly, because the points are stored like this 1734994.3283045683 5740529.6114465743 ( x, y )

Geography requires values between 90 and -90 as well as 180 and -180.

How can I do this? I've been Googling for the last 4 days and can't find a solution. I wouldn't mind writing any code (C#, Python, SQL, etc)

I have no shapefile or anything else, just the data in the DB.

1

Easy way ? Install postGIS , import data , create geoms (st_GeomFromWKT('POINT(' || x_col ||' ' || y_col || ') , SetSrdi to your espg code, use ST_Transform(geom. 4326), Update old x and y values using UPDATE ttt SET xcol = ST_X(geom), ycol = ST_Y(geom) , export data back to MS SQL.

Another easy way is create spatial database into MS SQL (2008 R2+) , create geom (GeomFromWKT) (remember define current srid). Get QGIS , configure MS SQL layer support, Import layer from MS SQL, save layer into shp file (im not sure can you save layer into database) and when saving select 4326 as srid. If you dont get MS SQL layer support to work, one option is export data to Qgis using csv format.

Long as you use 4326 (wgs84) srid, you can create geography and geometry types from it. Far as i know there is no free/open source solution for in database transformations. C# libraries like http://csharp-source.net/open-source/geospatial/proj-net are one option if you need to do transformations and you want to code. Also there is GDAL and proj4 libraries and tools for windows

  • 1
    This actually really helped. The most flexible way for me was to write a small application that uses proj4 to transform the points. – user853710 Apr 16 '14 at 18:20
  • The only problem using this approach was to find the appropriate proj4 transformation strings. – user853710 Apr 16 '14 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.