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.

  • $\begingroup$ 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? $\endgroup$ Aug 20, 2016 at 7:13
  • $\begingroup$ @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. $\endgroup$ Aug 20, 2016 at 8:15
  • $\begingroup$ 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. $\endgroup$ Aug 20, 2016 at 8:20
  • $\begingroup$ 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? $\endgroup$
    – Spacedman
    Aug 20, 2016 at 12:46
  • $\begingroup$ @Spacedman Please see edit. $\endgroup$ Aug 20, 2016 at 18:58

1 Answer 1


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) 
  • 2
    $\begingroup$ 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) $\endgroup$ Aug 20, 2016 at 19:01
  • 1
    $\begingroup$ 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 ;) $\endgroup$ Aug 20, 2016 at 19:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.