0

I have latitude, longitude coordinates as follows

latitude      longitude   
41.775974     -71.329887  
42.184913     -71.9179
41.682957373  -71.56037000

I want to use it as one of the features in a RandomForest classification. How to use it as a meaningful format?

Why i need this to be a standard format is Random forest is a classification algorithm if we use lat, long coordinates as a feature for classification means, the number or somewhat similar the difference is .6 or .5. so we cannot go and use lat long coordinates directly as a feature

  • 1
    why not just "as is" ? Please explain why you want to do this by editing your question. – radouxju Oct 24 '16 at 12:03
1

I do not track what you are after here. It makes no sense to convert coordinates to a "categorical" variable in regard to "feature means" in a recursive partitioning model. However, that aside, it is sensible to convert geographic coordinates to a distance based projection (projection units in meters or feet). In this way, the scaled statistical relationships are in distance and not time. Adding spatial coordinates to a model is referred to as a providing "naive spatial structure".

You can coerce your data into a sp class object and then use spTransform to convert the coordinates to something more relevant. Since you do not provide much information in your question it is difficult to provide any additional guidance. Here is a quick example of converting your data to a projected system.

library(sp)
dat <- data.frame(latitude = c(41.775974, 42.184913, 41.682957373),
                  longitude = c(-71.329887,-71.9179,-71.56037000))
coordinates(dat) <- ~longitude+latitude
proj4string(dat) <- "+proj=longlat +ellps=GRS80"                  
dat <- spTransform(dat, CRS=CRS("+proj=merc +ellps=GRS80"))       
( dat.coords <- coordinates(dat) )     

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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