TransmogrifAI icon indicating copy to clipboard operation
TransmogrifAI copied to clipboard

Geolocation to Country transformer

Open tovbinm opened this issue 5 years ago • 8 comments

Problem We would like to be able to treat GeoLocation values as categorical features.

Solution Add unary transformer to convert Geolocation values into Country.

Alternatives N/A

tovbinm avatar Oct 08 '18 20:10 tovbinm

Working on this.

sachitdabas avatar Oct 20 '18 06:10 sachitdabas

Is the idea to use a reverse geolocation service?

http://www.geonames.org/export/web-services.html#countrysubdiv OR https://developers.google.com/maps/documentation/geocoding/start?csw=1#ReverseGeocoding

ybh6336 avatar Dec 04 '18 05:12 ybh6336

@ybh6336 the idea is to use some kind of a binary file containing the information of geolocation -> country code (@ybh6336 do you know of any good one?). But we would provide an interface for users to replace is with a remote service if needed.

tovbinm avatar Dec 04 '18 22:12 tovbinm

@tovbinm I stumbled across the following projects which do offline reverse geocoding. Do these look in line with what you were thinking?

https://github.com/AReallyGoodName/OfflineReverseGeocode (java) https://github.com/thampiman/reverse-geocoder (python)

ybh6336 avatar Dec 05 '18 23:12 ybh6336

Yes, but if possible simpler ;) For a start we would like to have a transformer to return a country code from a pair of coordinates.

tovbinm avatar Dec 05 '18 23:12 tovbinm

Hello! I'm just getting started with TransmogrifAI and I'd love to work on this issue. I see a couple of attempts marked 'Closed,' but this issue is still marked 'open.' Is this issue still accepting solutions?

devansh2001 avatar Apr 30 '20 22:04 devansh2001

We closed those cause there were no use-case for us to support exploration of this direction further.

You can have a look of what I did https://github.com/salesforce/TransmogrifAI/pull/227. It was based on the idea of mapping each (lat,lon) coordinate to the nearest city, and then assuming the country of that city as the result. This approach would operate correctly on majority of coordinates, but still have some edge cases.

An alternative approach was to locate a encoded country borders map, convert it to convex polygons, then query which polygon contains each location. Unfortunately no good source of publicly accessible country borders was found.

tovbinm avatar May 01 '20 04:05 tovbinm

Got it, thanks so much! I'll get back to this if I find a reliable public service, and I'll look into other issues to fix or features to implement. :-)

devansh2001 avatar May 01 '20 05:05 devansh2001