Batch update coordinates of hosted FeatureLayer

1053
7
Jump to solution
01-07-2018 07:38 AM
MichaelLodes2
Occasional Contributor

Hi all,

I am looking for a solution with which I can do fast coordinate updates of FeatureLayer objects hosted on ArcGIS Online. I guess with applyEdits() function I just can update "normal" attributes, but not the geometries/graphics information. A big amount of points has to be updated programmatically everytime. (Background: application provides a csv import with 5000-10000 datasets including new point coordinates). New points also have to be created, if dataset is not existing in hosted FeatureLayer yet.

How could I do this with good performance?

Best Regards,

Michael

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Michael,

I guess with applyEdits() function I just can update "normal" attributes, but not the geometries/graphics information.

No that is not correct applyEdits is the way to update geometry and /or attributes for a editable layer.

https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#applyedits 

View solution in original post

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

Michael,

I guess with applyEdits() function I just can update "normal" attributes, but not the geometries/graphics information.

No that is not correct applyEdits is the way to update geometry and /or attributes for a editable layer.

https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#applyedits 

0 Kudos
MichaelLodes2
Occasional Contributor

Thank you very much, I work with JS API 4.6, but solved it anyway. Is this an efficient way to update thousands of features or do you know a faster way?

var feature = new Graphic({
  geometry: {
    type: "point", 
    longitude: 10.784112,
    latitude: 48.124298
  },
  attributes: {FID: 3}
});

lyr.applyEdits({
  updateFeatures: [feature]
});
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Michael,

   Are you recreating each graphic or just updating the existing graphics geometry?

0 Kudos
MichaelLodes2
Occasional Contributor

I just want to push two coordinates into each dataset of an ArcGIS Online table  ( = update each datasets' coordinates). If dataset with requested object id is not existing yet, a new dataset has to be created in that table. In most cases, datasets are updated and not have to be created newly

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

What you have in your previous post is good then as long as you are not doing a applyEdits for each feature. You only need one applyEdits unless you are going to batch the edits in smaller blocks.

MichaelLodes2
Occasional Contributor

I think I'm going to batch the edits in one block if that implies better performance. So what would be the syntax then? Like this?

var feature = new Graphic({
  geometry: {
    type: "point", 
    longitude: 10.784112,
    latitude: 48.124298
  },
  attributes: {FID: 3}
});

var feature1 = new Graphic({
  geometry: {
    type: "point", 
    longitude: 11.784112,
    latitude: 50.124298
  },
  attributes: {FID: 3}
});

var feature2.....

lyr.applyEdits({
  updateFeatures: [feature, feature1, ...]
});
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yes. But this is how I would have the code (no need to create a var for each feature if you are only going to add it to an array and send to applyEdits):

var featArr = [];

featArr.push(new Graphic({
  geometry: {
    type: "point", 
    longitude: 10.784112,
    latitude: 48.124298
  },
  attributes: {FID: 3}
}));

featArr.push(new Graphic({
  geometry: {
    type: "point", 
    longitude: 11.784112,
    latitude: 50.124298
  },
  attributes: {FID: 4}
}));

lyr.applyEdits({
  updateFeatures: featArr
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍