I am working on a project where I have to build a deep-learning model that classifies the kind of stop a vehicle at. My dataset consists of some vehicle related data such as vehicle Id, type of vehicle and so on, and GPS related data like longitude and latitude of the vehicle along the route, standard deviation and duration. As an initial step, I'm trying to build a model that takes all the input I have for the moment without any feature engineering. I have read that the model will converge faster if I feed normalized data to it. However, I've seen some models that are not using the normalized data (such as the famous house price prediction model). So my question is, How should I normalize coordinates!?


2 Answers 2


Not all models are sensitive to data normalization. For example, models with batch-norm layer have a built-in mechanism to fix activations distribution. Others are more sensitive and may even diverge just because of lack of normalization (E.g., try to train a CNN on CIFAR-10 dataset with training images, which pixels are in range $[0, 255]$).

But I'm not aware of any model that would suffer from data normalization. So even though the house prediction model (btw, which one exactly?) may not do it, the model is likely to improve if the data is normalized, and you should do it too.

GPS data has roughly these bounds: the latitude is in $[-100, 100]$, the longitude is in $[-200, 200]$. The coordinates for the populated area are much narrower, but it's not it's not a big deal to assume these wide ranges. This means that the transformation...

$$ x \mapsto \frac{x}{100}$$

... will ensure that the latitude is in $[-1, 1]$ and longitude is in $[-2, 2]$ (and very likely in $[-1, 1]$ as well), which are fairly robust ranges for deep learning. The transformation is easy (in numpy it takes just one line of code) and doesn't require you to compute the statistics from the training data.

  • 1
    $\begingroup$ Thanks @Maxim. I dig your answer especially that I'm dealing with coordinates from northern Europe so limited ranges already and normalizing by 100 would definitely solve the issue. I will give it a shot and see :) $\endgroup$
    – DieDen
    Feb 28, 2018 at 7:49
  • $\begingroup$ Hi @DieDen Im curious about how are you handling floating point precision for lat, long? Like for London the max lat is 51.565776 and the min lat is 51.446217 (in my dataset).. I'm just dropping the 51 for now but not sure what's best $\endgroup$
    – Soumyajit
    Aug 19, 2021 at 15:29

I think the answer of Maxim is not wrong, but might be misleading. When you use lon, lat values for tasks like vehicle stop classification, you probably look for a normalized space, where you can simply learn latent features like distances, speed or acceleration. The problem with longitude and latitude values is, that you can not simply infer the distances from it. A $\Delta(lon, lat)$ would lead to different distances depending, if you are at the equator or at one of the polar circle. For your task I would recommend something proposed by this answer of Jan van der Vegt:

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

These features can then be standardized properly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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