I was wondering, Is there any tool/ script to calculate the centroid point in WGS (Latitude and Longitude) of the each polygon which are in NAD_1983_UTM_Zone_15N projection system ?
Suppose the point has below x,y and needs to convert in to Decimal degrees.
X =1057502.154938
Y =11252250.240797
I would try Calculate Geometry Attributes, setting a coordinate system to DD.
You can specify two new fields, specify the coordinate system, and the DD coordinate output format.
You will get your polygon feature class with the centroid fields added with the DD values.
In Python:
arcpy.management.CalculateGeometryAttributes(
in_features="Test",
geometry_property="X_coord CENTROID_X;Y_Coord CENTROID_Y",
length_unit="",
area_unit="",
coordinate_system='GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]',
coordinate_format="DD"
)
I have tried this tool and working as expected. I need to update centroids of a polygon in latitude and longitude automatically whenever we create a new feature/ split/ merge features. it should behave like a trigger in SQL.
You could do this as an attribute rule I suspect - I've done that to calculate automatically calculate coordinate data when adding or updating records before. Another approach I use currently is the pyproj module in a script I run every month to convert lat/lon values to state plane coordinates but you can go the other way as well - this works for me since I am starting with non-spatial data at the outset and this saves me from having to create an intermediate spatial dataset.
You might dig into attribute rules. I'm not sure if you can set up such a rule.
https://developers.arcgis.com/arcade/profiles/attribute-rule-calculation/
I tried that too and didn't find any arcade expression to do the same functionality and need a formulae to convert.
Can I run python script in SQL Server Trigger ? If yes , what is syntax of it
I want to use the below tool get the Lat and Long and I don't have clue, how to run this in SQl Trigger
arcpy.PointGeometry()
y por que no haces una regla de atributo que te devuelva el centroide con Centroid($feature) en arcade? https://developers.arcgis.com/arcade/function-reference/geometry_functions/
entiendo que si deseas que cada polígono te cada vez que se cree o divida con una regla de atributo no se diferencia mucho de un Trigger porque hace lo mismo y la puedes dejar en el campo o campos para crearla y luego si quieres cambiar de Calcular el centroide en WGS (DD) a partir de la característica poligonal ((NAD_1983_UTM_Zone_15N) para esto hay varios e incluso lo último de arcade ya tenía una creada para ese cambio.
este lo creamos para meterlo como texto pero el tuyo debe ser mucho más sencillo espero que te sirva de ayuda
Latitud:
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lat = (Floor(Geometry($feature).Y,7) / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
var latitud = Floor(lat, 7)
if(latitud > 0){
return latitud + " N"
}else{
return latitud + " S"
}
Longitud:
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (Floor(Geometry($feature).X,7) / originShift) * 180.0;
var longitud = Floor(lon, 7)
if(longitud > 0){
return longitud + " E"
}else{
return longitud + " O"
}
solo debería añadirle además lo del centroide y tendría que salir mediante reglas de atributos
I tried, it returns always 0.
I tried same in Arcade playground,it was giving wrong results