transfer polygon from feature layer to survey123

663
1
03-21-2023 01:35 AM
tendtreesTC
Occasional Contributor

Hi there,

I have been given a view to a feature layer containing a number of polygon assets.

I need to create an audit against these assets and as I only have view access the best option is to create an audit survey in survey123 and use a popup to send the relevant data across.

This has worked fine in the past for point data however, I have never had to send polygon geometry across.

I found a number of posts relating to this but have not been able to make them work.

below is an example of the code I have been using for point data:

function MetersToLatLon(x, y) {
// Converts XY point from Spherical Mercator EPSG:3857(Web Mercator Auxiliary Sphere) to lat/lon in WGS84 Datum (EPSG:4326).
// Source: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
var originShift = 2.0 * PI * 6378137.0 / 2.0;

var lon = (x / originShift) * 180.0;
var lat = (y / originShift) * 180.0;

lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return [lat, lon];
}
function CreateURLSurvey(lat, lon) {
var url_scheme = "https://survey123.arcgis.app?itemID=a7e89264efb44ade9d4639eb37ec3aca";
var url = url_scheme + "&field:tree_id="+DomainName($feature,"OBJECTID")
+"&field:site_name="+Replace($feature.address_full,' ','_')
+"&field:species="+Replace(DomainName($feature,"botanical_name"),' ','_')
;// Repeat this line as many times as required based on how many fields you want populated. For this example AssetID will be populated from otherfeatid
var url = url + "&center=" + lat + "," + lon;// This is the line that defines the location
Console(url);
return url;
}

var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);
var url = CreateURLSurvey(latlon[0], latlon[1]);
return url;

 

 

0 Kudos
1 Reply
geoMcFly
New Contributor

Hi,

I've done something similar to what you're asking about.  My workflow was however trying to leverage passing a polygon geometry (coordinate pairs) to an URL that would be passed into Survey123, specifically for Mobile Survey123 on iOS.  What I noticed was that the polygon coordinate pairs would not work as expected once I created the mmpk using ArcGIS Pro 3.x.  My current situation is that I can only use ArcGIS Pro 2.7 to have the coordinate pairs pass into Survey123.  Below is my Arcade expressions and code to pass the geometry into Survey123.

 

// Name: polycoord
function MetersToLatLon(x, y) {
    // Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
    var originShift = 2.0 * PI * 6378137.0 / 2.0;

    var lon = (x / originShift) * 180.0;
    var lat = (y / originShift) * 180.0;

    lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
    return Concatenate(TEXT(lat)," ", TEXT(lon));
}


var geom = Geometry($feature);
var firstpart = geom.rings[0];
var outparts = [];
var counter = 0;
for (var pt in firstpart){
    var ptstr = MetersToLatLon(firstpart[pt].x,firstpart[pt].y);
    outparts[counter]= ptstr;
    counter = counter + 1;   
}
return Concatenate(outparts, ";")

 

 

Our popup expression for the FieldMaps mmpk link to populate Survey123 is as follows:

 

arcgis-survey123:///?itemID={removed}&field:tenure_num={TENURE_NUMBER_ID}&field:minename={CLAIM_NAME}&field:title_type={TITLE_TYPE_CODE}&field:operator={OWNER_NAME}&field:Parcel_polygon={expression/polycoord}&center={expression/polycoord}

 

 

0 Kudos