maptools

Quadrats in Spatstat

与世无争的帅哥 提交于 2021-01-07 01:28:26
问题 I am now doing exploratory analysis and the objective is to plot a quadrat map, determine if there exists complete spatial randomness (visually and using chi-square test), etc. However, I am having trouble plotting a quadrat map. I previously asked this question that led me to reproject my data. Here is my code: library(rgdal) #Brings Spatial Data in R library(spatstat) # Spatial Statistics library(maptools) library(raster) # Load nyc zip code boundary polygon shapefile s <- readOGR("/Users

How to reduce white space margins of world map

北城余情 提交于 2020-04-10 09:20:20
问题 library(maptools) data(wrld_simpl) plot(wrld_simpl) box() This gives me a world map and shows the plentiful white space top and bottom of the map. I would like this space to be gone as I need to print many (~60) maps. I am using knitr for the report in which the maps will be embedded. E.g. Here is some text. <<chunk.maps, eval = TRUE>>= library(maptools) plot(wrld_simpl) box() @ And some more text. But I don't think this is a knitr question. So: How can I get rid of the white space? How can I

How to reduce white space margins of world map

半世苍凉 提交于 2020-04-10 09:19:23
问题 library(maptools) data(wrld_simpl) plot(wrld_simpl) box() This gives me a world map and shows the plentiful white space top and bottom of the map. I would like this space to be gone as I need to print many (~60) maps. I am using knitr for the report in which the maps will be embedded. E.g. Here is some text. <<chunk.maps, eval = TRUE>>= library(maptools) plot(wrld_simpl) box() @ And some more text. But I don't think this is a knitr question. So: How can I get rid of the white space? How can I

US border line is not added to geom_map maps of dispersed US regions

眉间皱痕 提交于 2020-01-14 12:49:07
问题 I have a map of dispersed parts in the Us. This is in the following question (that contains link to the data): mapping by ggplot2 geom_polygon goes crazy after merging data It was answered very well. Then I tried to add the US border line, therefore I added the geom_path to the answered code,but no result, it creates the same map just containing the dispersed areas. library(ggplot2) #library(tidyverse) library(dplyr) library(maps) load("./data.rda") usa <- map_data("usa") shape_map <- tbl_df

US border line is not added to geom_map maps of dispersed US regions

[亡魂溺海] 提交于 2020-01-14 12:47:09
问题 I have a map of dispersed parts in the Us. This is in the following question (that contains link to the data): mapping by ggplot2 geom_polygon goes crazy after merging data It was answered very well. Then I tried to add the US border line, therefore I added the geom_path to the answered code,but no result, it creates the same map just containing the dispersed areas. library(ggplot2) #library(tidyverse) library(dplyr) library(maps) load("./data.rda") usa <- map_data("usa") shape_map <- tbl_df

Boundary polygon of lat lon collection

耗尽温柔 提交于 2020-01-04 11:02:41
问题 I have a table containing all the latitudes and longitudes of some locations in a city called queryResult and I do the following: 1 - Get the Raster map of the city[Blackpool for instance] cityMapRaster = get_map(location = 'Blackpool', zoom = 12, source = 'google', maptype = 'roadmap') dataToShow <- ggmap(cityMapRaster) + geom_point(aes(x = Longitude, y = Latitude), data = queryResult, alpha = .5, color = "darkred", size = 1) print(dataToShow) and this will return the following points on the

Removing the Great Lakes from US county-level maps in R

二次信任 提交于 2019-12-31 02:25:15
问题 I am using R to draw US map at county level. I downloaded the shapefile for US from GADM. The county-level shape file is "gadm36_USA_2.shp". I then used the code below to draw map: library(sf) library(tidyverse) us2 <- st_read("<Path>\\gadm36_USA_2.shp") mainland2 <- ggplot(data = us2) + geom_sf(aes(fill = NAME_2), size = 0.4, color = "black") + coord_sf(crs = st_crs(2163), xlim = c(-2500000, 2500000), ylim = c(-2300000, 730000)) + guides(fill = F) The Great Lakes region (shown by red arrows)

R: plotting neighbouring countries using maptools

青春壹個敷衍的年華 提交于 2019-12-20 04:25:10
问题 Say I am plotting countries on a world map using maptools, if I were to plot a country, is there a way of plotting the countries that border this country in a different colour? I am using the shapefile wrld_simpl that comes with maptools, so say I plot China: plot(wrld_simpl[wrld_simpl$NAME=='China',], col='red', add=T) is there a way I can get it to plot all the bordering countries to China. I want to be able to do this for lots of different countries so I'd ideally want a general solution,

Error opening SHP file in R using maptools readShapePoly

风流意气都作罢 提交于 2019-12-18 14:16:13
问题 I am new to R and was following the following tutorial on the ggplot2 package found here. However the readShapePoly() function throws an error whenever I try to load the basic shapefile. I have used the following code: library("ggplot2") library("gpclib") library("maptools") setwd("~/Documents/R Projects/Intro to ggplot2") #Intro to ggplot 2 contains the .shp file and associated data sport <- readShapePoly("london_sport.shp") which gets me: Error in getinfo.shape(filen) : Error opening SHP

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

懵懂的女人 提交于 2019-12-17 15:27:33
问题 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")