[R] Shapefile

From: <Felipe_Carrillo_at_fws.gov>
Date: Wed, 23 Jun 2010 14:45:10 -0700

Hopefully the attachment will make it this time...

I am practicing with the attached shapefile and was wondering if I can get some help. Haven't used 'rgdal' and 'maptools' much but it appears to be a great way bring map data into R. Please take a look at the comments and let me know if I need to explain better what I am trying to accomplish.


wolves.map <- readOGR(dsn=dsn, layer="PNW_wolf_habitat_grid") class(wolves.map)
wolves.ds <- fortify(wolves.map)
# Shapefile of 5 states

wolves.plot <- ggplot(wolves.ds,aes(long,lat,group=group)) + geom_polygon(colour='white',fill='lightblue') wolves.plot
# How to show the state borders of Washington, Oregon, Idaho, Montana
and Wyoming on map?

# Subset from wolves to create a logistic regression model based on
WOLVES_99 and then apply to all the 5 states
# Remove the WOLVES_99 2(two value) and use "one" for presence and
"zero" for absence to end up with 153 records.
#wolfsub <- subset(wolves.map,WOLVES_99!=2)
wolfsub <- wolves.map[!wolves.map$WOLVES_99 %in% 2,];wolfsub dim(wolfsub)
# 42 = Forest, 51 = Shrub, > 81 = Agriculture

# create the model

mod1<-glm(WOLVES_99~RD_DENSITY+Forest+Shrub +Agriculture,family=binomial,data=wolfsub) summary(mod1)


# Add the wolfsub data to the map to see the map
wolfsub <- fortify(wolfsub);names(wolfsub) area_mod <- wolves.plot + geom_polygon(data=wolfsub,aes(fill=????))
#Want to fill by WOLVES_99 but is gone #after fortify
#Not sure how to proceed from here to fit the 'mod1' model to all
#the 5 states.

  From: Tom Hopper <tomhopper_at_gmail.com>   To: Felipe Carrillo <mazatlanmexico_at_yahoo.com>   Sent: Tue, June 22, 2010 9:40:19 PM
  Subject: Re: Plotting Data on a Map


  I am just learning these tools, too, so it may be a good learning   opportunity for both of us. Please send me the files and I will try to   put it together and plot it.



  On Mon, Jun 21, 2010 at 11:57 PM, Felipe Carrillo <   mazatlanmexico_at_yahoo.com> wrote:
   Hi Tom:
   I am just starting to use rgdal and maptools but I have a long way to    go. I went to a training
   a couple of weeks ago and the instructor showed us a csv file and a    shapefile with wolf data from
   a national park in the midwest. I am trying to put all of the csv data    and some predicted data
   on a map using ggplot2 but I am stuck with it. I am just trying to do    this example because I want to
   see if I can apply this example to fish. Let me know if interested.

                             (See attached file: Data.zip)


R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 23 Jun 2010 - 21:58:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jun 2010 - 22:20:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive