Select to view content in your preferred language

Arcade modify only Z geometry

592
4
12-28-2023 06:34 AM
FlorentChalvet
Emerging Contributor

Hello everyone,

In the exemple below, i can create another point with the Z coordinate of the field "Z_OUV" in stead of the original Z coordinate. But is it possible to modify the current point and not create another one?

if ($feature.Z_OUV == Geometry($feature).z) {
  return
};

var newGeom = Point({
  hasZ: true,
  x: Geometry($feature).x,
  y: Geometry($feature).y,
  z: $feature.Z_OUV,
  spatialReference: { wkid: 4326 }
});

var featureID = $feature.OBJECTID;
var f = filter(FeatureSetByName($datastore, "WaterDevice"), "OBJECTID = @featureID");
if (count(f) == 0) return $feature.Z_OUV;
var featureAct = first(f);

return {
  "result": $feature.Z_OUV,
  "edit": [{  
    "className" : "WaterDevice",
    "updates" : [
      { 
      "OBJECTID": featureAct.OBJECTID,
      "geometry": newGeom
      }
    ]}
]}

I tried to just update the "z" in the geometry section, but was met with an error. Is there a way to just modify one coordinate?

"geometry": {"z": $feature.Z_OUV}

 

0 Kudos
4 Replies
Bud
by
Esteemed Contributor

I remember trying something similar a while back, but I wanted to change the M-values of lines. I’m too rusty to help at this point, but you could check out my old M-value posts:

0 Kudos
FlorentChalvet
Emerging Contributor

Hey!

Thanks for the reply. I've checked your old posts, and there was the explanation for why it didn't work.

FlorentChalvet_0-1704358075979.png

If geometries are immutable, then I don't think I can modify only one attribute of the geometry...

 

MikeMillerGIS
Esri Frequent Contributor

You need to pass back a complete geometry object.  So copy your geoemtry(can do this by calling Dictionary(geo) on it, prior to 3.2, you need to call Dictionary(Text(geo))).  Modify the Z and then pass that dict into the geometry constructor.

0 Kudos
FlorentChalvet
Emerging Contributor

Hey! I'm on 2.8 right now. Working with a Dictionary is doable, but I still create a new geometry who has the exact same attributes as the first one instead of modifying the current one.

var newGeom = Dictionary(Text(Geometry($feature)))
newGeom['z'] = $feature.Z_OUV
newGeom['hasZ'] = true
var testGeom = Geometry(newGeom)

I also needed to add a 'hasZ' attribute to the dictionary for it to create a valid geometry.

0 Kudos