Select to view content in your preferred language

"Is the point inside the polygon" geopoint and geoshape in different layers and different forms

251
2
Jump to solution
06-15-2024 07:56 AM
corete_potagere
New Contributor II

Hi community,

For a research project, I need to visit buildings that are part of plots and complete a survey form for each building (the layer containing the building polygons is the main one). My survey has a "plot" repeat/layer that only needs to be filled out once per plot by drawing a polygon in the shape of the plot. To summarize, for each new form, the question is asked: "Has a form already been completed for a building in the same plot?" Yes/No. If no, then a polygon representing the perimeter of the plot must be drawn and is stored in the "plot" layer. If yes, then the "draw the plot" part is skipped, but a geopoint must be recorded at the location of the building.

I need this geopoint to contain a field that automatically updates according to a value from the plot polygons that were created in previous forms. In other words: is the geopoint contained within a polygon from the "plot" layer? If yes, then copy the value of the "x" field.

This operation needs to be done dynamically because the obtained value determines the continuation of the survey.

Do you have any idea how to achieve this? I hope my question makes sense.

Thank you in advance!

1 Solution

Accepted Solutions
corete_potagere
New Contributor II

Thanks aburaux! That's a good point. I actually ended up doing it with a slightly different approach. I wrote a js script that automatically calculates the centroid of each building polygon as a geopoint whenever a form is opened, instead of using the device's geolocation or a user-drawn geopoint. This way, it's straightforward to extract data from the plot polygons using "pulldata("@layer")". I'm happy to share the script if anyone's interested - it's not rocket science, but it can be useful since Survey123 doesn't have this functionality built-in.

I can mark this thread as solved.

View solution in original post

2 Replies
abureaux
MVP Regular Contributor

I foresee an issue with geolocation. Let's say a polygon exists at a property, and the user drops a point to skip tracing the border. That geopoint has two issues: 1) accuracy - it could appear further away than intended, or even in an adjacent plot, and 2) where the user is standing - maybe they are filling this question in before entering the plot area, meaning you wont trigger the operation. I'd at least consider these possibilities if you haven't already.

Pulling data from a polygon can be done via pulldata("@layer")

0 Kudos
corete_potagere
New Contributor II

Thanks aburaux! That's a good point. I actually ended up doing it with a slightly different approach. I wrote a js script that automatically calculates the centroid of each building polygon as a geopoint whenever a form is opened, instead of using the device's geolocation or a user-drawn geopoint. This way, it's straightforward to extract data from the plot polygons using "pulldata("@layer")". I'm happy to share the script if anyone's interested - it's not rocket science, but it can be useful since Survey123 doesn't have this functionality built-in.

I can mark this thread as solved.