# Ways to deal with longitude/latitude feature [closed]

I am working on a fictional dataset with 25 features. Two of the features are latitude and longitude of a place and others are pH values, elevation, windSpeed etc with varying ranges. I can perform normalization on the other features but how do I approach latitude/longitude features?

Edit: This is a problem to predict agriculture yield. I would think lat/long is very important since locations can be vital in prediction and hence the dilemma.

• Could you clarify why you don't think that you can normalise those features? Presumably they are numerical the same as other features, so you can take mean/sd? Is your concern about having natural measure of distance between locations? If so, does the data cover a small area (with similar values) or is it global? – Neil Slater Aug 20 '16 at 7:13
• @NeilSlater It's just that intuitively it does not make sense to me to normalize these features. Will the information not be lost if normalized? I have the dataset covering counties of America. – AllThingsScience Aug 20 '16 at 8:15
• What information do you think will be lost? It probably will not be actually lost, but if you explain in your question what your concern is, someone will be able to answer. Not knowing any more, I would just normalise regardless - for fully global values and some problems (where distance between points is important) I might create a 3d cartesian co-ordinates feature from the long/lat. – Neil Slater Aug 20 '16 at 8:20
• What's your question here? What are you trying to find out from the data? Correlation? Clustering? Classification? Prediction? Interpolation? How is location important to your model? – Spacedman Aug 20 '16 at 12:46
• @Spacedman Please see edit. – AllThingsScience Aug 20 '16 at 18:58

## 1 Answer

Lat long coordinates have a problem that they are 2 features that represent a three dimensional space. This means that the long coordinate goes all around, which means the two most extreme values are actually very close together. I've dealt with this problem a few times and what I do in this case is map them to x, y and z coordinates. This means close points in these 3 dimensions are also close in reality. Depending on the use case you can disregard the changes in height and map them to a perfect sphere. These features can then be standardized properly.

To clarify (summarised from the comments):

x = cos(lat) * cos(lon)
y = cos(lat) * sin(lon),
z = sin(lat)

• That is very interesting. Thank you! Could you confirm if these are the formulas for conversion? x = R * cos(lat) * cos(lon), y = R * cos(lat) * sin(lon), z = R *sin(lat) – AllThingsScience Aug 20 '16 at 19:01
• I don't have access to my code at the moment but it looks right. You don't need the R since you will be standardizing anyway ;) – Jan van der Vegt Aug 20 '16 at 19:07
• Perfect! Thank you. – AllThingsScience Aug 20 '16 at 19:46