Exact Definition and Format for Microdegrees for GeoPoint

1,056 views
Skip to first unread message

Day Davis Waterbury

unread,
May 2, 2016, 4:40:03 PM5/2/16
to AdWords API Forum
What exact format is expected the latitudeInMicroDegrees and longitudeInMicroDegrees when creating a geoPoint for a Proximity CampaignCriterion? 


For example, when I have a latitude in decimal degrees of 45.3911638 and I convert it to microdegrees as 45391163, I am seeing the following error:


[CriterionError.INVALID_LATITUDE @ operations[0].operand.criterion.geoPoint.latitudeInMicroDegrees]>

Here's my code:

    {
      :operator => 'ADD',
      :operand => {
        :campaign_id => self[:campaign_id],
        :criterion => {
          :xsi_type => 'Proximity',
          :geo_point => {
            :latitude_in_micro_degrees => (shop[:lat] * 1_000_000).to_i,
            :latitude_in_micro_degrees => (shop[:lng] * 1_000_000).to_i
          },
          :radius_distance_units => RADIUS_DISTANCE_UNITS,
          :radius_in_units => radius
        }
      }
    }

Shwetha Vastrad (AdWords API Team)

unread,
May 2, 2016, 6:11:24 PM5/2/16
to AdWords API Forum
Hi,

You are probably receiving this error because of the longitude value being passed, not because of the latitude value passed. In the code provided, you are setting the value of the latitude twice. You need to change the second line to "longitude_in_micro_degrees". This should take care of the "INVALID_LATITUDE" error.

Cheers,
Shwetha, AdWords API Team.

Day Davis Waterbury

unread,
May 2, 2016, 6:37:39 PM5/2/16
to AdWords API Forum
Thank you. That's very helpful. I will try that and post a follow-up. Thanks again!

Day Davis Waterbury

unread,
May 3, 2016, 3:13:07 PM5/3/16
to AdWords API Forum
Yes. You were correct. Thanks for spotting that. Worked fine when that was fixed.

As for the follow-up on the original question, "What exact format is expected for the latitudeInMicroDegrees and longitudeInMicroDegrees when creating a geoPoint for a Proximity CampaignCriterion?"

For example, Google's documentation merely states:

xsd:int

Micro degrees for the latitude.

This field is required and should not be null.

But, as it turns out, one microdegree is one millionth of one degree. So, assuming your latitude and longitude values are in decimal degrees (https://en.wikipedia.org/wiki/Decimal_degrees), you multiply by 1,000,000 and round to the nearest integer value. It's important to have 7 decimal places of precision so you can round to 6.


Thanks again!

Shwetha Vastrad (AdWords API Team)

unread,
May 3, 2016, 4:47:44 PM5/3/16
to AdWords API Forum
Hi,

Glad to hear that everything was error free. 

And, yes, you are right. Since both latitudes and longitudes are represented in micro degrees, having 7 decimal places of precision helps in rounding up or down. 
Reply all
Reply to author
Forward
0 new messages