Select to view content in your preferred language

Constructing polygon Geometry for Geoshape from existing feature

1166
5
09-18-2023 03:23 AM
DeanMoiler_MapAction
New Contributor II

Hi Everyone,

I'm trying to construct the geometry as an answer for a geoshape feature using the calculate field, and am running into some difficulties.

Firstly I am performing a pulldata @layer getRecordAt request from an AGOL polygon feature layer:

pulldata("@layer", "getRecordAt", "${polygon_feature}", ${Address_activity_location})

and was then using @json calculation to extract the geometry attribute and populate the geoshape this way

"" + string(pulldata("@json",${geometry_query},"geometry"))

 

[I've tried multiple iterations of the above calculation with and without the "" + string but have only gotten it working in Survey123 Connect and not via the published survey. I have also increased bind::esri:fieldLength to 50000 to capture all of the coordinates and aim to reduce precision in the query when it's working]

 

I end up with the polygon geometry as the answer:

"pcode_polygon": {
    "rings": [
        [
            [
            80.2224833796995,
            7.52764666203902
            ],
            [
            80.2227977900489,
            7.5276021333672
            ],

........... etc...

 

and when used to populate the geoshape in Survey123 Connect, this works and displays the geometry correctly, but it doesn't when published to Survey123 and real records are submitted in the survey. The geometry appears empty.

I've since discovered the appropriate format for constructing geoshape/geotrace is:

Individual vertices that make up the answer to a geotrace or geoshape question are space-separated sets of latitude and longitude values (in decimal degrees) separated by a semicolon.

-37.842156723211474 144.95942945338243; -37.83554486071995 144.9726235713864; -37.85681405373047 144.98240735651922; -37.85954045531896 144.97715349053766

I think I could construct the geometry were I able to perform find/replace style regex against "geometry.rings" , but can only seem to find a way to use regex to apply constraints.

 

Are there any ways to construct appropriate geometry from the existing geometry data? Or is there some simpler construct / copy geometry operation available to perform this that would be more appropriate?

 

Thanks!

 

5 Replies
ZacharySutherby
Esri Regular Contributor

Hello @DeanMoiler_MapAction

You should be able to use sum(string(pulldata("@json",${geometry_query},"geometry"))). The Query a Feature Layer sample available in Connect demonstrates how to calculate a geoshape question based on geometry returned from a feature service.

Thank you,
Zach
mikAMD
by
Occasional Contributor III

Where does one find this "Query a Feature Layer sample available in Connect" ??

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello @mikAMD

Open ArcGIS Survey123 Connect, select the New survey icon on the top left, log into your ArcGIS organization if not already, in the pop up under the Esri section select Samples, in the search bar you can enter Query a Feature Layer which will filter the list to just the one sample. 

ZacharySutherby_0-1697735035069.png

I you do not see the Esri section in the pop up you or your organization administrator will need to go to the Organization settings in the Survey123 website and enable Templates and samples from Esri. 

ZacharySutherby_1-1697735207539.png

 

Thank you,
Zach
mikAMD
by
Occasional Contributor III

Yes thank you so much!!!

Finally managed to generate polygon from feature service.

0 Kudos
DeanMoiler_MapAction
New Contributor II

Hi @ZacharySutherby,

That was very helpful, thank you for this and apologies for the delayed response! I did manage to find this sample separately (somewhere) online, but I couldn't get it to submit geometry records (always loading gif displays) so I thought it was just an old sample. From the looks the problem is caused due to difference between browser submission vs app submission of surveys.

I didn't realise that this workflow does not work (and I think I ready somewhere it is not currently supported?) when surveys are completed in the browser, and only returns geometry when using the survey123 app. I have seen this documented somewhere, but have not been able to find it again!

I had it working in survey123 connect a long time ago, but could never get it to work when submitting in the browser app. I never even though to test submission in the survey123 app itself. One to keep in mind in future.

Needing the app installed to submit surveys does hamper the workflow I'm trying to achieve where I would hope to make the survey accessible to different aid organisations that would not have ArcGIS Survey123 app installed, and probably wouldn't have the option to install when in the field. This would mean duplication of 

Q: Is there any likelihood that the geometry extraction capability will be made possible via the web browser submission rather than just survey123 app, or have I gotten something completely wrong and it should be possible?

Thanks!

Dean

0 Kudos