Skip to main content

Hi,

I have 2 polygons
files: one for cities and one for provinces. I need to have a table in excel
which allow people to choose a province and the result is all the cities which
are in the selected province and the cities which are in the provinces which touch
the selected province.

  • -How
    can I get this table in excel
  • -If
    I want to let people use FME server, how can I do it?

I start
using Spatial relator (using province polygon as requestor and as supplier),
then ListExploder but I do not know how to go farther..

Thanks

The Names of features in a polygon can be retrieved by using the Overlayer transformers (PointonAreaOverlayer, LineOnAreaOverlayer and AreaonAreaOverlayer). The adjacent polygon can be found using the NeighborFinder. A combination of both will give you the names of features in the adjacent polygon.


Hi @miladahmad, alternatively the SpatialRelator can be used, as you have planned.

Collect inside cities for each province

Send the province polygons to the Requestor port, send all city polygons to the Candidate port, and set "Contains" to the "Tests to Perform" parameter.

Each output feature (province) will have a list called "_relationships" by default, which stores all attributes of spatially related cities.

Note: If the province boundary doesn't match the inside city boundaries exactly, consider using the Bufferer to create buffers for each province by a slight amount beforehand, so that the inside cities can be collected without omission.

Collect adjoining provinces for each province

Send the province polygons to both the Requestor and Candidate port simultaneously, set "Touches" to the "Tests to Perform" parameter, and set an attribute unique for each province (e.g. province code or name) to the "Attribute(s) that Must Differ" parameter.

The "_relationships" list of output features stores all attributes of adjoining provinces.

Note: The "Touches" predicate should work theoretically, but "Intersects" might be better practically, if the boundaries between adjoining provinces don't match exactly.


Then, for each process above, you can extract elements of the "_relationships" list with the ListExploder, to prepare saving the contents into a table.


Once you have created tables storing the result, you can create another workspace which executes queries against the tables, to get inside cities and adjoining provinces of a selected province, and also inside cities of the adjoining provinces.


Thanks for
answer.. Actually I'm already using the same solution as proposed by takashi but
I still have problem : 1- Let’s say that we have a prov1 with 3 neighbors
prov2, prov3, prov4. I got the polygons of the prov2, pro3, prov4 but I did not
get the polygon of prov1.

2- After ListExploder
how I can go farther.

(My
solution in ArcMap which works well: I
did spatial join one to many for the same file (provinces) and the relation is BOUNDARY_TOUCHES
then I used the file of cities and the results one (provinces touche) and I did
a spatial relation one to many.. the result in excel is OK.)


Hi @miladahmad,

  1. I guess you don't have resolved conflict of the ID attribute names between Requestor and Candidates. Try setting the "Prefix Incoming List" to the "Accumulation Mode" parameter, or renaming ID attribute of Candidates before inputting them to the SpatialRelator.
  2.  Depending on how you will query the result. Just an idea. If you save the result in a table containing ID field and Neighbor_ID field, you can collect neighbor IDs of a selected polygon ID with this query, for example.
select ID, Neighbor_ID from table_name where ID = selected_ID

See also the attachment: collect-neighbor-polygons.fmw (FME 2015.1.3+)


Hi takashi..

Its work..
(Sorry I had an error in the provinces file itself.. )..

Is-it
possible to have the result something like: one geometry for every province and
dynamically the name of prov2, prov3, prov4 as attribute (dynamically, because
some time we have 2 prov as neighbors.. some time we have 5, etc..)..

The second
question:

If I want
to use FME server (url within a html) and I want people do a query and get the result
(people write the name of city) and they get name of the province itself and
the name of the province which touch it.. Is there any example to do that..
thanks


Hi takashi..

Its work..
(Sorry I had an error in the provinces file itself.. )..

Is-it
possible to have the result something like: one geometry for every province and
dynamically the name of prov2, prov3, prov4 as attribute (dynamically, because
some time we have 2 prov as neighbors.. some time we have 5, etc..)..

The second
question:

If I want
to use FME server (url within a html) and I want people do a query and get the result
(people write the name of city) and they get name of the province itself and
the name of the province which touch it.. Is there any example to do that..
thanks

  1. You can use the ListConcatenator to concatenate elements of a list. Assuming that an attribute called "name" stores the province name, connect a ListConcatenator to the Output port of the SpatialRelator and set "_relationships{}.name" to the "List Attribute" parameter.
  2. Try searching the Knowledge Base.

thanks.. I did not mean ListConactenator.. I mean to create attribute name neihbor_prov1, neighbor_prov2, etc.

(5 attributes if we have the max count neighbors 5) (not manually). and set the value of theses attributes from (list (index 1 go to neighbor_prov1, index 2 go to neighbor_prov1, ect.)..


..use listindexer...


thanks.. I did not mean ListConactenator.. I mean to create attribute name neihbor_prov1, neighbor_prov2, etc.

(5 attributes if we have the max count neighbors 5) (not manually). and set the value of theses attributes from (list (index 1 go to neighbor_prov1, index 2 go to neighbor_prov1, ect.)..

Hi @miladahmad, maybe the BulkAttributeRenamer can be used. Alternatively scripting...

See the attachment: collect-neighbor-polygons-2.fmw (FME 2015.1.3+)


Hi Takashi,

Thanks a lot. It is great..
It works and I have learned a lot from this example (collect-neighbor-polygons-2)..

Wish you a great day


Reply