Calculate area

Hi.
I am in need of an example form, for measuring surfaces. I also need the calculation of the area in hectares.
Could someone facilitate me?

Hi @Marcelo_Raul_SCARONE
everything is in the doc https://docs.opendatakit.org/form-question-types/#calculating-the-area-of-a-geoshape

Yes, but I don't know how to design a form with an area question and area calculation in hectares. Anyone have any form already in excel, what can I take as an example?

There is a sample XLSForm form with a geoshape and area calculation in the ODK docs - please follow the link provided above:

If you want the area in hectares, just divide the calculated area (in m^2) by 10000

1 Like

Thanks! But I cannot access to the link!

type 	        name 	           label 	        calculation
geoshape 	shape 	           Record a Geoshape 	 
calculate 	shape_area 	  	                area(${shape})
calculate 	rounded_shape_area 	         	round(${shape_area}, 2)
note 	        shape_area_note    The area of the recorded geoshape is: ${rounded_shape_area} m²

To measure the area, from a geotrace, is the same procedure?

The area() function assumes a geoshape; that is, the last coord is the same as the first. Depending on what client you happen to be using the underlying algorithm that perform this calculation may or may not handle it being different, as will be the case if you give it a geotrace [eg Enketo and ODK Collect/javaRosa use entirely different XPath libraries].

So you really should first convert your geotrace to an equivalent geoshape before trying to calculate an area() from it. You can do this with the likes of:

first = substring-before(${mygeotrace}, ';')
mygeoshape = concat(${mygeotrace}, ';', ${first})
area = area(${mygeoshape})

(obviously dont try this with a geotrace of 2 or fewer points...)

Finally one more question ... Attached is a form in xls format, where from a geotrace I get the calculation of the area, but the result is in square meters. How can I do to get the result in hectares?formulario de prueba 2.xlsx (8.6 KB)

1ha = 10 000 square meters so you just need to add /10000 after round(${trace_area}, 2) I believe.

It didn't work by adding "/ 10000". Can I appeal to your goodwill? I urgently need to get the results of my geotrace in hectares. I have no problem obtaining the area in square meters, but what else should I add to my form to have the result in hectares?formulario de prueba 2.xlsx (8.8 KB)

ohh it should be div 10000 not /10000 sorry.