mazatlanmexico at yahoo.com
Thu Jun 24 03:42:04 CEST 2010
The shapefile data can be downloaded from the link below:
download all the six files and save them on your working directory
and make sure the dsn path is set to where the files are saved.
My shapefiles are saved on C:/Data.
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 to 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")
wolves.ds <- fortify(wolves.map)
# Shapefile of 5 states
wolves.plot <- ggplot(wolves.ds,aes(long,lat,group=group)) +
# 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 <- wolves.map[!wolves.map$WOLVES_99 %in% 2,];wolfsub
# 42 = Forest, 51 = Shrub, > 81 = Agriculture
# Create the model
# 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.
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
More information about the R-help