[R-sig-Geo] Export subsets of Spatial Points Data Frame to images

Frede Aakmann Tøgersen frtog at vestas.com
Mon Jan 5 08:22:02 CET 2015


Hi Ariel

Please provide a reproducible example. Now I have to guess what the SB object is because you didn't provide any details about that.

I guess that the group_by() and summarise() are from the dplyr package. 

I guess that when you have imported the csv file you have an object SB containing columns Fecha, CodPar, x, and y.

If so, your calls to the two dplyr functions are not correct. As first argument they need a data object, which is supposed to be of a tbl type like e.g. data frame.

Why didn't you get an error when issuing e.g. group_by(Fecha, CodPar, x, y) instead of group_by(SB, Fecha, CodPar, x, y)?

Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog at vestas.com
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender. 

> -----Original Message-----
> From: R-sig-Geo [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Ariel
> Fuentesdi
> Sent: 5. januar 2015 04:48
> To: r-sig-geo at r-project.org
> Subject: [R-sig-Geo] Export subsets of Spatial Points Data Frame to images
> 
> I have a csv file, which I converted it to Spatial Points Data Frame. And I
> want to split the spatial data and export each map to a jpg file.
> 
> 
> I did the following:
> 
>     SB <- read.csv("SB_040914.csv", header=TRUE, sep = ";")
>     SB <- SB %>% group_by(Fecha, CodPar, x, y) %>%
> summarise(mean(Sube),mean(Evade), mean(Baja))
>     SB <- data.frame(SB)
>     SB <- SB[complete.cases(SB),]
> 
>     coordinates(SB) <- ~ x + y
>     proj4string(obj = SB) <- CRS("+init=epsg:32719")
> 
>     SB <- split(SB, f = SB$Fecha)
> 
> The Split function, shows me the next warnings:
> 
> **Warning messages:
> 1: In min(x) : no non-missing arguments to min; returning Inf
> 2: In max(x) : no non-missing arguments to max; returning -Inf
> 3: In min(x) : no non-missing arguments to min; returning Inf
> 4: In max(x) : no non-missing arguments to max; returning -Inf**
> 
> And for trying to export I did this:
> 
>     for (i in SB) {
>       jpeg(paste(SB[[1]],".jpg",sep=""))
>       bubble(SB[[i]], "mean.Evade.", col=c("#00ff0088", "#00ff0088"),
>              main = "Evasión" )
>       dev.off()
>     }
> 
> **Which shows me the next error:
> Error in as.character.default(<S4 object of class
> "SpatialPointsDataFrame">) :
>   no method for coercing this S4 class to a vector
> 6 as.character.default(<S4 object of class
> structure("SpatialPointsDataFrame", package = "sp")>)
> 5 as.character(<S4 object of class structure("SpatialPointsDataFrame",
> package = "sp")>)
> 4 paste(SB[[1]], ".jpg", sep = "")
> 3 gsub("%%", "", s)
> 2 checkIntFormat(filename)
> 1 jpeg(paste(SB[[1]], ".jpg", sep = ""))**
> 
> 	[[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