18
$\begingroup$

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.

$\endgroup$

closed as unclear what you're asking by Spacedman, Dawny33, Sean Owen Aug 20 '16 at 17:20

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\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$ – Neil Slater Aug 20 '16 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$ – AllThingsScience Aug 20 '16 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$ – Neil Slater Aug 20 '16 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 '16 at 12:46
  • $\begingroup$ @Spacedman Please see edit. $\endgroup$ – AllThingsScience Aug 20 '16 at 18:58
22
$\begingroup$

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) 
$\endgroup$
  • 1
    $\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$ – AllThingsScience Aug 20 '16 at 19:01
  • $\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$ – Jan van der Vegt Aug 20 '16 at 19:07
  • $\begingroup$ Perfect! Thank you. $\endgroup$ – AllThingsScience Aug 20 '16 at 19:46

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