I'm looking for solutions for auto-fill attribute table fields of spatial layer on QGIS from updates in geometry.
All layers were created as polygon shapefiles. Attribute table fields are dependent on feature geometry. For example, there are fields that return the latitude and longitude of the centroid of polygons, and other fields that calculate how far the geometry are in North-South and East-West directions from a reference point.
Currently, I need to run a sequence of expressions to recalculate those values.
I would like to know if there is a solution for these expressions run in an automated way, as I need to improve the means of maintaining the system so other people can manage the data.
If necessary, I can change the format of the files for geopackage or other formats. I read something about triggering in SQL, but have a great difficulty with the syntax to implement.
Below are the expressions of the attribute table.
LATITUDE
ROUND(Y( centroid( $geometry)),0)
LONGITUDE
ROUND(x( centroid( $geometry)),0)
COD_LAT
case
when abs("LATITUDE" - 7535757) <10 then '0000' || abs("LATITUDE" - 7535757)
when abs("LATITUDE" - 7535757) <100 then '000' || abs("LATITUDE" - 7535757)
when abs("LATITUDE" - 7535757) <1000 then '00' || abs("LATITUDE" - 7535757)
when abs("LATITUDE" - 7535757) <10000 then '0' || abs("LATITUDE" - 7535757)
end
COD_LON
case
when abs("LONGITUDE" - 513632) <10 then '0000' || abs("LONGITUDE" - 513632)
when abs("LONGITUDE" - 513632) <100 then '000' || abs("LONGITUDE" - 513632)
when abs("LONGITUDE" - 513632) <1000 then '00' || abs("LONGITUDE" - 513632)
when abs("LONGITUDE" - 513632) <10000 then '0' || abs("LONGITUDE" - 513632)
end
COD_LATD
case
when "LATITUDE" >= 7535757 then 'N'
when "LATITUDE" < 7535757 then 'S'
end
COD_LOND
case
when "LONGITUDE" >= 513632 then 'E'
when "LONGITUDE" < 513632 then 'W'
end
COD_LOTE
CONCAT(COD_LAT,COD_LATD,COD_LOND,COD_LON)