Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have some trouble with sql server 2012.

I store coordinates of french cities in my database as geography object (with ESRI 4326) and i want to make the UNION of some cities.

I have in result (with the method AsTEXT() ) :

  • If I ask for 100 cities : FULLGLOBE
  • If I ask for 1 cities : I have the good coordinates

There is a limit of how many cities i can union ?

(I do my sql request in c# with ASP .NET MVC 4 :

DbGeography result = System.Data.Spatial.DbGeography.PointFromText("POINT EMPTY", 4326);

//PolygonFromText("POLYGON((0 0,0 1,1 0, 0 0))", 4326);;    
string resultString = "";

try
{
  var commune = db.Communes
    .Where(com => com.IDCommune.StartsWith("073"))
    .Select(com => com);

  foreach(var com in commune)
  {
    if (com.coordinates == null)
    {

    }
    else
    {                       
      result = result.Union(com.coordinates);
    }                   
  }

Thank you !

EDIT / I solved my problem : i put my polygon in geometry type and not in geography type ans it works =)

share|improve this question
    
Your english translation is hard to understand. Can you possibly clarify? –  nagytech Apr 2 '13 at 8:09
    
I have trouble when i use SQl STUnion() method. When i request more than the union of 2 cities, the result is "FULLGLOBE". –  ROCHEDY Apr 2 '13 at 8:20

1 Answer 1

This isn't an answer, but it won't fit in a comment

I'm not sure STUnion is the correct tool for what you're hoping to achieve, especially since the union of several points is just another list of the points. See the example below:

DECLARE @p1 geometry = geometry::STGeomFromText('POINT(1 1)', 4326);
DECLARE @p2 geometry = geometry::STGeomFromText('POINT(-1 -1)', 4326);
SELECT @p1.STUnion(@p2).ToString(); 

// Output: MULTIPOINT ((1 1), (-1 -1))

Is the end result supposed to be a bounding box of all the points? If so, there are other ways to go about this.

share|improve this answer
    
I solve this in storing my POLYGONS with the type geometry and not geography ! –  ROCHEDY Apr 9 '13 at 7:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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