Can not convert geometry polygon to geography


hi,

i kept getting error doing below , not find wrong. can take look?

declare @geog geography;
declare @geom geometry;


set @geom = geometry::stpolyfromtext('polygon((101.672729 3.106615,101.674123 3.108650,101.674067 3.110243,101.672484 3.114602,101.672489 3.114701,101.676913 3.115032,101.677854 3.115422,101.679595 3.114258,101.682601 3.112739,101.686587 3.112115,101.688313 3.111350,101.694240 3.104536,101.695499 3.102511,101.696886 3.101461,101.695710 3.098697,101.695138 3.096237,101.695293 3.092493,101.698320 3.084698,101.702435 3.080928,101.703026 3.078771,101.702230 3.074790,101.703138 3.063713,101.704564 3.057330,101.705382 3.050862,101.702204 3.050689,101.698317 3.049582,101.690278 3.048998,101.679846 3.048987,101.673437 3.048943,101.673313 3.048761,101.673334 3.047441,101.673511 3.043867,101.672355 3.042247,101.672240 3.038895,101.671049 3.037673,101.664741 3.036156,101.664570 3.035070,101.649260 3.034952,101.636260 3.034944,101.635901 3.037785,101.632650 3.039883,101.631166 3.039528,101.630202 3.040778,101.627679 3.042344,101.628887 3.044759,101.632300 3.045590,101.633048 3.046620,101.632695 3.049429,101.625376 3.050387,101.620154 3.054541,101.617430 3.056373,101.615318 3.058156,101.618245 3.059763,101.619433 3.068790,101.620459 3.071334,101.622002 3.073351,101.621459 3.077336,101.622743 3.077964,101.624341 3.080588,101.626051 3.084464,101.629632 3.084332,101.631734 3.084223,101.646500 3.081966,101.648402 3.081910,101.650478 3.081828,101.651951 3.081659,101.656113 3.081614,101.660317 3.082865,101.664570 3.084622,101.666941 3.086903,101.669592 3.088133,101.670016 3.088801,101.670010 3.089700,101.669793 3.092784,101.669361 3.096330,101.670607 3.098411,101.671364 3.101454,101.672350 3.105324,101.672729 3.106615))'
    , 0);

select @geom, @geom.isvaliddetailed()  -- valid.

set @geog = geography::stpolyfromtext(@geom.stastext(), 4326)
-- go below error.
-- cannot find point in other hemisphere. , valid ring orientation should too.


msg 6522, level 16, state 1, line 17
.net framework error occurred during execution of user-defined routine or aggregate "geography":
microsoft.sqlserver.types.glargumentexception: 24205: specified input not represent valid geography instance because exceeds single hemisphere. each geography instance must fit inside single hemisphere. common reason error polygon has wrong ring orientation. create larger hemisphere geography instance, upgrade version of sql server , change database compatibility level @ least 110.
microsoft.sqlserver.types.glargumentexception:
   @ microsoft.sqlserver.types.glnativemethods.geodeticisvalid(geodata& g, double eccentricity, boolean forcekatmai)
   @ microsoft.sqlserver.types.sqlgeography.isvalidexpensive(boolean forcekatmai)
   @ microsoft.sqlserver.types.sqlgeography..ctor(geodata g, int32 srid)
   @ microsoft.sqlserver.types.sqlgeography.geographyfromtext(opengistype type, sqlchars taggedtext, int32 srid)


hi olaf,

i figured out. ring orientation. forgot 1 step.

set @geom = @geom.stunion(@geom.ststartpoint());

usually makevalid() , stunion() together. time, checked stisvalid() (and isvaliddetail()) , thought "well, it's good."

btw, using sql 2014 (upgraded sql 2008). mentioned, sql 2014 take wrong polygon produced before?

thanks again,

john



SQL Server  >  SQL Server Spatial



Comments

Popular posts from this blog

Reindexing

Users List

List of charts