Hexagon Geospatial
MENU

Spatial Modeler Tutorials

Learn more about our products, find answers, get the latest updates, and connect with other Hexagon Geospatial product users, or get support from our professional service team.
Showing results for 
Search instead for 
Do you mean 

Determining the type of geometry present in the primary geometry field of features (snippet)

by Technical Evangelist ‎06-07-2018 09:56 AM - edited ‎06-08-2018 05:08 AM (409 Views)

 

Description:

 

This Spatial Recipe is a small snippet intended to demonstrate how to solve a specific problem, not as a stand-alone model. As such I haven't provided a downloadable version - it's straightforward enough to be replicated from scratch based on the screenshots below.

 

Problem: "if I need to branch my logic within a model by geometry type (of the primary geometry field), so that it does one thing if areas are input, another if points are input, etc. – how do I do that? I recalled correctly that there are PrimaryGeometryFieldName and PrimaryGeometryFieldCRS ports on the Features Information operator; but I mistakenly thought there was also PrimaryGeometryFieldType as well. That seems a gap, so I’m hoping one of you knows a clever way to get this information by another route."

 

Solution: "The Model below does the trick. It matches the primary geometry field in the field names and uses that index to index into the field types. Since in the general case "Find Item” may return multiple results, you have to select the zeroth item knowing that there will be only one."

 

This is obviously something that should be added to Features Information in a future release, but in the meantime, here's the snippet:

 

primary_geometry_type.PNG


NOTE: The Create Centroid operator is present solely to ensure that this example had a features stream which contained more than a single geometry field per feature. In this instance there are both Area (from the original shapefile input) and Point (created by the Create Centroid operator) geometry types. The Primary geometry type is correctly identified as being of type Point.

 

If using this snippet in your own model (e.g. to control downstream processing via an If Else branch) you just need to feed your own Features stream into the Features Information operator:

 

 

 

Courses
Contributors