Yes, you either store the base location attribute on user profile or fetch it using some API at runtime and use this information in the custom rule to check against location provided in the current transaction.
UBP might not solve your use case as this more of behavior adaptive/self-learning model where for initial few attempts it may challenge the user for step-up authentication for the new location but once the user starts authenticating himself/herself form this location frequently UBP will adapt to this behavior and stop challenging user for this new location as then UBP will consider this a normal deviation for the user.
Also, UBP for third-party integration is like a black box i.e. you might not get weight specific to location rather you will get an overall model score.
You can compose some kind of User Location Velocity rule to determine user frequency to authenticate from a certain location ( by default OOTB rule builder provide one Action Velocticy rule composition and you should explore this area).