[R] Getting unknown error trying to plot spatial data

mjkatsaros mjkatsaros7156 at gmail.com
Sat Aug 4 21:09:57 CEST 2012


Hi there! I'm following an awesome guide to working with spatial data
(http://www.frankdavenport.com/blog/2012/6/19/notes-from-a-recent-spatial-r-class-i-gave.html)
and am running into an error that I can't figure out how to fix.

Disclaimer: I am very much an R n00b

Here is the r script I am running:
https://dl.dropbox.com/u/28231177/This%20Should%20Work.R

data: https://dl.dropbox.com/u/28231177/my_data.csv

shapefile: https://dl.dropbox.com/u/28231177/sfzipcodes.zip

I am getting two errors:

> pds <- fortify(sf_map)
*Using OBJECTID to define regions.*
> pds$OBJECTID <- as.integer(pds$OBJECTID)
*Error in `$<-.data.frame`(`*tmp*`, "OBJECTID", value = integer(0)) : 
  replacement has 0 rows, data has 16249*
> 	
> 
> ## Make the map
> 
> p1 <- ggplot(my_data, aes(map_id = zip))
> p1 <- p1 + geom_map(aes(fill=vol, map_id = zip), map = pds)
> p1 <- p1 + expand_limits(x = pds$lon, y = pds$lat) + coord_equal()
> p1 + xlab("Basic Map with Default Elements")
*Error in unit(x, default.units) : 'x' and 'units' must have length > 0*

Anybody have any idea what is happening here or how to resolve this?

Thanks!!!!



--
View this message in context: http://r.789695.n4.nabble.com/Getting-unknown-error-trying-to-plot-spatial-data-tp4639179.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list