Measure Half power beam width in the E-plane and H-plane. Multiply them and invert and again multiply with 4*pi. The result will be approximate far field directivity. Now multiply directivity with efficiency to calculate Gain. Efficiency is anoter parameter that you have to know.
if you have the complete pattern (full theta-phi measurement) you can get the directivity to high accuracy, however you will not have efficiency and therefore no gain info.
To get the gain you need to know the ohmic losses of the antenna (conductor and dielectric loss) , or at least a good estimate. In case you know or assume a low loss antenna, then directivity equals the gain.