Skip to main content
deleted 41 characters in body
Source Link
Bera
  • 77.9k
  • 14
  • 78
  • 188

One easy way is to execute Refactor field manually. Add the field and calculate with the expression now(), and delete whatever fields you like:

enter image description here

Then press Ctrl+Alt+H and copy paste the code, replace my input with your merged layer:

processing.run("native:refactorfields", {'INPUT':'C:/GIS/data/tempdata/grid.shp','FIELDS_MAPPING':[{'expression': '\"id\"','length': 20,'name': 'id','precision': 0,'type': 6},{'expression': '\"left\"','length': 23,'name': 'left','precision': 15,'type': 6},{'expression': '\"top\"','length': 23,'name': 'top','precision': 15,'type': 6},{'expression': '\"right\"','length': 23,'name': 'right','precision': 15,'type': 6},{'expression': '\"bottom\"','length': 23,'name': 'bottom','precision': 15,'type': 6},{'expression': 'now()','length': 0,'name': 'now','precision': 0,'type': 14}],'OUTPUT':'TEMPORARY_OUTPUT'})

One easy way is to execute Refactor field manually. Add the field and calculate with the expression now(), and delete whatever fields you like:

enter image description here

Then press Ctrl+Alt+H and copy paste the code, replace my input with your merged layer:

processing.run("native:refactorfields", {'INPUT':'C:/GIS/data/tempdata/grid.shp','FIELDS_MAPPING':[{'expression': '\"id\"','length': 20,'name': 'id','precision': 0,'type': 6},{'expression': '\"left\"','length': 23,'name': 'left','precision': 15,'type': 6},{'expression': '\"top\"','length': 23,'name': 'top','precision': 15,'type': 6},{'expression': '\"right\"','length': 23,'name': 'right','precision': 15,'type': 6},{'expression': '\"bottom\"','length': 23,'name': 'bottom','precision': 15,'type': 6},{'expression': 'now()','length': 0,'name': 'now','precision': 0,'type': 14}],'OUTPUT':'TEMPORARY_OUTPUT'})

One easy way is to execute Refactor field manually. Add the field and calculate with the expression now(), and delete whatever fields you like:

enter image description here

Then press Ctrl+Alt+H and copy paste the code:

processing.run("native:refactorfields", {'INPUT':'C:/GIS/data/tempdata/grid.shp','FIELDS_MAPPING':[{'expression': '\"id\"','length': 20,'name': 'id','precision': 0,'type': 6},{'expression': '\"left\"','length': 23,'name': 'left','precision': 15,'type': 6},{'expression': '\"top\"','length': 23,'name': 'top','precision': 15,'type': 6},{'expression': '\"right\"','length': 23,'name': 'right','precision': 15,'type': 6},{'expression': '\"bottom\"','length': 23,'name': 'bottom','precision': 15,'type': 6},{'expression': 'now()','length': 0,'name': 'now','precision': 0,'type': 14}],'OUTPUT':'TEMPORARY_OUTPUT'})
Source Link
Bera
  • 77.9k
  • 14
  • 78
  • 188

One easy way is to execute Refactor field manually. Add the field and calculate with the expression now(), and delete whatever fields you like:

enter image description here

Then press Ctrl+Alt+H and copy paste the code, replace my input with your merged layer:

processing.run("native:refactorfields", {'INPUT':'C:/GIS/data/tempdata/grid.shp','FIELDS_MAPPING':[{'expression': '\"id\"','length': 20,'name': 'id','precision': 0,'type': 6},{'expression': '\"left\"','length': 23,'name': 'left','precision': 15,'type': 6},{'expression': '\"top\"','length': 23,'name': 'top','precision': 15,'type': 6},{'expression': '\"right\"','length': 23,'name': 'right','precision': 15,'type': 6},{'expression': '\"bottom\"','length': 23,'name': 'bottom','precision': 15,'type': 6},{'expression': 'now()','length': 0,'name': 'now','precision': 0,'type': 14}],'OUTPUT':'TEMPORARY_OUTPUT'})