maptools

Converting spatial polygon to regular data frame without use of gpclib tools

只谈情不闲聊 提交于 2019-11-28 07:40:10
问题 I working with spatial data in R for a commercial application and would like to use ggplot2 for data visualization. If you run the Hadley's example at https://github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles you find that in order to run the fortify command you need to enable the use of gpclib tools using gpclibPermit() . I'm looking for an efficient way (that doesn't involve manually hacking into the S4 object) to perform the same operation that fortify does here, i.e. take a

How to create a world map in R with specific countries filled in?

怎甘沉沦 提交于 2019-11-27 22:46:07
I would like to use R to generate a very basic world map with a specific set of countries filled with a red colour to indicate that they are malaria endemic countries. I have a list of these countries in a data frame but am struggling to overlay them on a world map. I have tried using the wrld_simpl object and also the joinCountryData2Map method in the rworldmap package. I would comment on this answer to prevent addition of a possibly redundant question but I do not have enough reputation at the moment, apologies for this. https://stackoverflow.com/a/9102797/1470099 I am having difficulty

Simple way to subset SpatialPolygonsDataFrame (i.e. delete polygons) by attribute in R

假如想象 提交于 2019-11-27 17:47:47
I would like simply delete some polygons from a SpatialPolygonsDataFrame object based on corresponding attribute values in the @data data frame so that I can plot a simplified/subsetted shapefile. So far I haven't found a way to do this. For example, let's say I want to delete all polygons from this world shapefile that have an area of less than 30000. How would I go about doing this? Or, similarly, how can I delete Antartica? require(maptools) getinfo.shape("TM_WORLD_BORDERS_SIMPL-0.3.shp") # Shapefile type: Polygon, (5), # of Shapes: 246 world.map <- readShapeSpatial("TM_WORLD_BORDERS_SIMPL

How to create a world map in R with specific countries filled in?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 04:36:27
问题 I would like to use R to generate a very basic world map with a specific set of countries filled with a red colour to indicate that they are malaria endemic countries. I have a list of these countries in a data frame but am struggling to overlay them on a world map. I have tried using the wrld_simpl object and also the joinCountryData2Map method in the rworldmap package. I would comment on this answer to prevent addition of a possibly redundant question but I do not have enough reputation at

Converting a “map” object to a “SpatialPolygon” object

夙愿已清 提交于 2019-11-27 03:15:06
问题 I am guessing there is a simple solution to the problem I have been having, but I am having some trouble. I am trying to convert the following map object: require(maps) usa <- map("state") into a SpatialPolygon object using the map2SpatialPolygons function: require(maptools) usa.sp <- map2SpatialPolygons(usa, IDs=usa$names,proj4string=CRS("+proj=longlat")) I keep getting the following error: Error in map2SpatialPolygons(usa, IDs = usa$names, proj4string = CRS("+proj=longlat")) : map and IDs

How to turn gpclibPermit() to TRUE

我的未来我决定 提交于 2019-11-26 16:41:43
问题 When I run gpclibPermit() , I've got the answer FALSE . How can I change it to be TRUE ? 回答1: I've struggled with the gpclibPermit issue myself. You don't provide a reproducible example, but I am guessing that you are having a sesion like this: library(maptools) Checking rgeos availability: FALSE Note: when rgeos is not available, polygon geometry computations in maptools depend on gpclib, which has a restricted licence. It is disabled by default; to enable gpclib, type gpclibPermit() >