[R-sig-Geo] Latitude Longitude to SPDF

Julian Burgos julian at hafro.is
Mon Sep 24 23:51:08 CEST 2012


Or you can use the coordinates() function:

library(sp)
loc <- data.frame(x=c(23.1,19.0),y=c(43.2,45.5),value=c(200,100))
coordinates(loc) = c("x","y")

Applied on a data.frame it returns a SpatialPointsDataFrame object.
If you are going to use it with other spatial data, make sure to define
the data projection using proj4string().

-- 
Julian Mariano Burgos, PhD
Hafrannsóknastofnunin/Marine Research Institute
Skúlagata 4, 121 Reykjavík, Iceland
Sími/Telephone : +354-5752037
Bréfsími/Telefax:  +354-5752001
Netfang/Email: julian at hafro.is


> you can try SpatialPointsDataFrame() in sp package.
> for example:
>
> library(sp)
> loc <- data.frame(x=c(23.1,19.0),y=c(43.2,45.5),value=c(200,100))
> spdf <- SpatialPointsDataFrame(loc[,1:2], loc)
>
>
>
>
>
> Mao-Gui Hu
> State Key Laboratory of Resources and Environmental Information System
> Institute of Geographic Sciences and Natural Resources Research, Chinese
> Academy of Sciences
>
> From: Bhupendrasinh Thakre
> Date: 2012-09-24 23:23
> To: r-sig-geo
> Subject: [R-sig-Geo] Latitude Longitude to SPDF
> Hi Team,
>
> Need your guidance in building SPDF objects from Latitude, Longitude
> Information available.
> I am using package "plotGoogleMaps" which is really awesome but it
> requires
> SPDF objects to build the maps.I have a data frame which have Latitude and
> Longitude information and wanted to convert it in SPDF for making maps.
>
> Please help me to find suitable package or function to convert it. Or if I
> am missing something. I am really sorry but have very less experience when
> dealing with Spatial Data.
>
> Best Regards,
>
>
> Bhupendrasinh Thakre
>
> *Disclaimer :*
>
> The information contained in this communication is confi...{{dropped:11}}
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list