Does anyone know if you can create point symbology from the center coordinate of a line feature using arcade?
I'm not sure if this will be helpful or not, but I'll post it anyway:
In similar situations where we don't have a Midpoint() function, such as in the St_Geometry spatial type in EGDBs, we've used the following hack:
Buffer the line and get the centroid of the resulting polygon. It's kind of like a "poor man's midpoint".
If I recall, that works ok. But I think I remember the point not being the exact midpoint of the line. I forget what the specific issue was. It's probably good enough for most use cases though...
Hi @XanderBakker ,Of course, thanks for the quick reply!We're looking to visualize construction features (lines and polygons hosted the same service) as points on the map at high scales.I know arcade built into the symbology setting doesn't support feature sets, but I was thinking since I have a point layer in the map, if there's a way to use the Point ( json ) (returns { Point }) function by getting the X,Y of the line/poly centroid through feature sets then it could be visualized through that layer. Thoughts?Thanks again!
Hi @Amanda__Huber ,
So in the symbology profile, Arcade could return a geometry, but this is not something that is valid and that can be used to draw those features. Can you elaborate a bit more on what you have and what you want to get (and explain the why in this a bit more)?
@XanderBakker,
In theory, if you use feature sets with this workflow could you use arcade on a separate point layer to represent the centroid of this line layer?
We're looking to do the same thing, but curious on your thoughts as we get started.
Thanks!
I don't think you can use Arcade to visualize polylines as points. The error message seems to refer to the spatial reference. I did a simple test on a hosted feature that I published using the same spatial reference as the base map and it returned the point:
var geom = Geometry($feature); Console('\ngeom:' + geom); var line = Polyline(geom); Console('\nline:' + line); var cent = Centroid(line); Console('\ncent:' + cent); var pnt = Point(cent); Console('\npnt:' + pnt); return pnt;<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Which yields:
geom:{"paths":[[[-8414259.482734734,697445.4680427602],[-8414258.288406167,697445.4680427602],[-8414258.288406167,697457.4113284288]]],"spatialReference":{"wkid":102100,"latestWkid":3857}} line:{"paths":[[[-8414259.482734734,697445.4680427602],[-8414258.288406167,697445.4680427602],[-8414258.288406167,697457.4113284288]]],"spatialReference":{"wkid":102100,"latestWkid":3857}} cent:{"x":-8414259.482734734,"y":697445.4680427602,"spatialReference":{"wkid":102100,"latestWkid":3857}} pnt:{"x":-8414259.482734734,"y":697445.4680427602,"spatialReference":{"wkid":102100,"latestWkid":3857}} <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
So it returns the point, but the symbology will no be what you want (they will remain lines, and you will have an object for your symbology that you cannot actually use):
I'm currently working on this for polygon features.
Using:
POINT (Centroid(Geometry($feature)))<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
But getting this error:
Execution Error:Cannot create Geometry in this SpatialReference. Engine is using a different spatial reference.<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.