Apply UnionAggregate to lat/long RRS feed

  • Question

  • Hello All,

    Spatial is new to me so I hope this is easier than it seems.  My end goal is to find the outer boundary of a bunch of geography polygons that have common edges (think states within a country) with the end result being rows of lat/long points.   I converted the lat/log just fine using

    select geography::Pointer(Lat,Long,4326) as LGA_Geo from source

    then unioned with 

    select Geography::UnionAggregate(LGA_Geo.MakeValid()) as Poly

    To get the lat/long back I tried 

    select poly.lap,poly.long from table
    but it returns null?

    Friday, August 1, 2014 6:28 AM


  • Hi Colin,

    To obtain a polygon from UnionAggregate you need to pass in a column that contains polygons. But from your code (which doesn't work as posted, so I'm not sure exactly how you're getting your results), you're passing in a column containing points (which UnionAggregate would make into a Multipoint). BTW, neither polygon nor multipoint will have a non-null Lat/Long property because it consists of multiple points. To get Lat/Long with such features, you need to use STPointN(n) to select a particular point in the feature.

    If you already have a table (source) that has a column (geoColumn) in which, for each row, the geoColumn column contains a Polygon, the syntax would be:

    SELECT geography::UnionAggregate(geoColumn) from source;

    Cheers, Bob

    • Edited by Bob Beauchemin Sunday, August 3, 2014 6:34 PM
    • Proposed as answer by Sofiya Li Monday, August 4, 2014 8:52 AM
    • Marked as answer by Sofiya Li Monday, August 11, 2014 6:31 AM
    Saturday, August 2, 2014 12:09 AM