# How to convert Geometry to Geography ?

• ### Question

Wednesday, July 2, 2014 4:16 AM

• Hello,

you can convert it e.g. via the textual representation of the geometry object:

```DECLARE @gm AS Geometry;
DECLARE @gg AS Geography;
SET @gm = geometry::STGeomFromText('LINESTRING (0 0, 20 20, 5 5)', 0);
SET @gg = geography::STGeomFromText(@gm.ToString(), 4326);

SELECT @gg;```

But geography do have a limited coordinate range (-180 .. 180), so ensure your geometry objects are in the same ranges.

Olaf Helper

[ Blog] [ Xing] [ MVP]

• Proposed as answer by Thursday, July 3, 2014 9:18 AM
• Marked as answer by Wednesday, July 9, 2014 7:01 AM
Wednesday, July 2, 2014 6:06 AM

### All replies

• Hello,

you can convert it e.g. via the textual representation of the geometry object:

```DECLARE @gm AS Geometry;
DECLARE @gg AS Geography;
SET @gm = geometry::STGeomFromText('LINESTRING (0 0, 20 20, 5 5)', 0);
SET @gg = geography::STGeomFromText(@gm.ToString(), 4326);

SELECT @gg;```

But geography do have a limited coordinate range (-180 .. 180), so ensure your geometry objects are in the same ranges.

Olaf Helper

[ Blog] [ Xing] [ MVP]

• Proposed as answer by Thursday, July 3, 2014 9:18 AM
• Marked as answer by Wednesday, July 9, 2014 7:01 AM
Wednesday, July 2, 2014 6:06 AM
• Do you already have geodetic data or are you trying to project a geometric (projected) coordinate system to geography? if you already have geodetic data the uses a well-known geodetic SRID (i.e. in sys.spatial_reference_systems), it's trivial. If you're trying to do reprojection (change the coordinate system) then you'll need a library like OGR2OGR or a product like SAFE software.

Cheers, Bob

Wednesday, July 2, 2014 5:02 PM