Question

Attribute polygons based on their location within a larger polygon

  • 14 April 2015
  • 6 replies
  • 0 views

Badge +1
Hi,

 

 

I have two datasets: 1) A polygon dataset made up of a series of square tiles. 2) A polygon dataset made up of a series of square tiles that are each one-quarter the size of the squares in the first polygon dataset.

 

 

Each tile in the 1st polygon dataset has a unique ID, and the four polygons in the 2nd dataset that relate locationally to the 1st polygon dataset, each have this same ID.

 

 

I want to label the tiles in the 2nd polygon dataset based on what quarter of the 1st polygon square they are located in. ie: NW, NE, SW, SE.  Does anyone have any ideas?

 

 

Thanks,

 

 

6 replies

Userlevel 2
Badge +17
Hi,

 

 

An idea.

 

(1) Create 4 corner points for each large square.

 

- Extract extent (xmin, ymin, xmax, ymax) of the square by a BoundsExtractor.

 

- Branch the flow into 4 streams; add VertexCreators on each stream to create the corner points.

 

NW corner: (xmin, ymax)

 

NE corner: (xmax, ymax)

 

SW corner: (xmin, ymin)

 

SE corner: (xmax, ymin)

 

- Connect AttributeCreators to each VertexCreator to add an attribute which indicates one of the locations {NW, NE, SW, SE} to the point.

 

 

(2) Merge the location attribute to the one-quarter squares by a SpatialFilter

 

Corner points (from the 4 streams) => Filter

 

One-quarter square => Candidate

 

Group By: ID of the large sqaure  * important!

 

Tests to Perform: Touches

 

 

If you have to consider some tolerance between the corner point and the one-quarter square, you can also use a NeighborFinder instead of the SpatialFilter.

 

 

Takashi
Userlevel 1
Badge +10
Use a centrepoint replacer, and then a neighbour finder with a group by on the ID and use the angle attribute to find out what quadrant the square falls into?
Badge +3
Assuming the two sets are aligned.

 

 

Create ID for larger tiles if you don't have that yet.

 

Create a centerpoint for the larger Tiles.

 

Create centerpoints for smaller tiles.

 

 

Relate the smaller tiles to the larger tiles, overlayer/spatialRealtor/Clipper or wichever you prefer.

 

Merge the centerpoints of the large tiles to the smaller tiles grouped by the ID (wich you created earlier).

 

Calculate angle. Test for quadrant.

 

(if you don't want to do the math, just create lines form the centepoint of large tile to the smaller tiles and use the Azimutcalculator).

 

 

 

 

....come to think of it, why the hassle?...

 

Just use a tiler in iterative mode and set to 4 on the larger tiles.

 

This wil create the smaller tiles.

 

The row and column id basicaly gives away the quadrant: 0,0; 02;0,4 etc. are lower leftquadrants.

 

 

 

To use Tiler iteratively u need to set the paralellproces mode in the navigator.

 

 

There are a couple of examples of this in this former. Search for iterative tiling.

 

 

.....on the other hand....you can also do without iterative tiler, by using a tiler on the extent of the large tiles with double the rows and double they columns. Then relate the set of smaller tiles to it. Again row/columnnumbers give awa the quadrant.

 

 

 

 

 
Userlevel 2
Badge +17
There are several ways :)

 

-----

 

(1) Calculate coordinate (xc, yc) of center point for each one-quarter square, using a BoundsExtractor and an AttributeCreator.

 

xc = (xmin + xmax) * 0.5

 

yc = (ymin + ymax) * 0.5

 

(2) Calculate coordinate (x0, y0) of center point for each large square, as well.

 

(3) Merge (x0, y0) to one-quarter squares by a FeatureMerger, joining on the polygon ID.

 

(4) Add the location attribute to the Merged features (one-quarter squares) by an AttributeCreator with conditional value setting.

 

If xc < x0 AND yc < y0 Then "SW"

 

Else If xc > x0 AND yc < y0 Then "SE"

 

Else If xc < x0 AND yc > y0 Then "NW"

 

Else "NE"

 

Badge +1
Thanks everyone.

 

 

I ended up using Takashi's first method successfully :)

 

 

I couldn't work out how to use the "Iterative" tiler mode..
Userlevel 2
Badge +17
Good to hear that you accomplished the purpose.

 

I think that the "iterative" tiler means a custom transformer which wraps a Tiler transformer and has a published parameter linking to the "Parallel Process By" parameter. You can find the parameter in the "Transformer Parameters / Advanced" section of the Navigator window for the custom transformer.

 

The "Parallel Process By" parameter is not same as the "Group By", but produces a similar result. 

Reply