Questions tagged [r-maptools]

The R package maptools provides a set of tools for manipulating and reading geographic data, in particular ESRI shapefiles.

The R package maptools is a set of tools for manipulating and reading data, in particular s. The package also provides interface wrappers for packages such as PBSmapping, spatstat, maps, RArcInfo, tmap, , , and others.

Repositories

Vignettes

Other resources

Related tags

157 questions
0
votes
0 answers

How to define an area at +- 1 along a road?

Considering a geographical line defined by the following spatiallinedataframe library(sp) library(rgeos) ## from the sp vignette: l1 <- cbind(c(1, 2, 3), c(3, 2, 2)) Sl1 <- Line(l1) S1 <- Lines(list(Sl1), ID = "a") Sl <- SpatialLines(list(S1)) ##…
Xavier Prudent
  • 1,570
  • 3
  • 25
  • 54
0
votes
0 answers

How can I overlay a road map on a geom_tile as a geom_path?

My data points are along two bus routes so I can draw out their paths using geom_path as in this image: I would like to have the rest of the roads in the area drawn in as well in the same manner without having to make data files of coordinates for…
0
votes
0 answers

How to convert a shapefile in map projection coordinates to geographic coordinates?

I am trying to use basemap to plot NYC with a shapefile. However, the shapefiles provided by NYC (https://www1.nyc.gov/site/planning/data-maps/open-data/districts-download-metadata.page) are don't use the proper coordinates to be read by the…
CrnlWes
  • 393
  • 3
  • 6
0
votes
1 answer

Problems with order of attributes of CRS 4326 in R

I load a shape file using R maptools package Subcat<-readShapeSpatial("Contour500/Catchments500.shp",proj4string = CRS('+init=epsg:4326')) class(Subcat) [1] "SpatialPolygonsDataFrame" attr(,"package") [1] "sp" Then I load another shape…
Juan Ossa
  • 1,153
  • 1
  • 10
  • 14
0
votes
1 answer

merging polygons of a SpatialPolygonDataframe

I have created a SpatialPolygonsDataFrame in which countries are associated with regions. Here is what it looks like https://cloudstor.aarnet.edu.au/plus/index.php/s/RpYr3xyMrmhaGKA (EDU link with data): As the object is too large to work with and…
Cecile
  • 527
  • 5
  • 22
0
votes
1 answer

In R split polyline with polyline

I have a polyline I would like to split into certain segments. And create a new polyline. The location where the polyline needs to be divided is where it intersects with another polyline. library(sp) library(maptools) library(rgeos) dir_shp <-…
IlhameO
  • 35
  • 7
0
votes
1 answer

Merge spatialpolygons with external data and select polygons on attribute

I am trying to plot my study area in R. So far I have downloaded census OA boundary data and I have merged attribute data to the OA I wish to look at. So lets say from a total of 1,000 OAs. I want to look at only 500 of these OAs, for which I have…
wilga
  • 103
  • 2
  • 7
0
votes
1 answer

Leaflet addPolylines is not plotting all values (or lines) of a data object

I'm using addPolylines to overlay contours of a specific value(s) on a leaflet generated web map, however, addPolylines is not plotting all the data that it is supplied with. As per the first image, at least two regions of a value of 125 are…
SatishR
  • 230
  • 3
  • 13
0
votes
1 answer

R: Find/match NUTS code in shapefile

where do I find the EU NUTS code in the shapefile in R? NUTS = Nomenclature of Territorial Units for Statistics Each NUTS region has a NUTS code: . You can also find the detailed NUTS codes in this Excel file. When I download the NUTS shapefile, I…
Thomas V.
  • 41
  • 5
0
votes
0 answers

Trouble merging shapefiles in R

I am having trouble merging shapefiles in R. Here is my code thus far: library(rgdal) library(maptools) library(gridExtra) setwd("/Users/Cornelius/Dropbox/Cornelius_Sharedfolder") #Load a geodatabase fgdb =…
Cornelius
  • 69
  • 1
  • 4
0
votes
1 answer

clipping spatial files in R

I am currently trying to clip one spatial file to another however the spatial file I get is not the right shape. I know with a raster you have to use a mask, is there a similar command for 2 shape files? c1 <- crop(spatial1, spatial2)
KerryLee
  • 373
  • 2
  • 5
  • 13
0
votes
1 answer

Shapefile: XY coordinate and Longitude/Latitude Coordinate

I have the following two shapefiles: > summary(precincts1) Object of class SpatialPolygonsDataFrame Coordinates: min max x -74.25545 -73.70002 y 40.49613 40.91540 Precinct Shape_Leng Shape_Area Min. : …
Ibuki
  • 13
  • 1
0
votes
1 answer

use maptools::sunriset() inside mutate

I'm trying to use dplyr to calculate sunrise time for a set of lon/lat/timestamp coordinates, using the sunriset function from maptools. Here is a reproducible example. library(maptools) library(dplyr) pts <- tbl_df(data.frame( …
Ben Carlson
  • 1,053
  • 2
  • 10
  • 18
0
votes
0 answers

Invalid `.internal.selfref` warning, column not updated working with `SpatialPolygonsDataFrame`

I'm trying to do some geospatial analysis in R which will involve adding attributes to SpatialPolygonsDataFrames for coloring, etc. during plotting. For organization, I'd like to add these attributes to my SpatialPolygonsDataFrames through a merge &…
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
0
votes
1 answer

Add a shaded layer to a map in R

I'm creating maps for individual schools within a district and want to create a shaded area around the school boundary. I'm able to do it manually using QGIS however would like to be able to produce something similar in R. I'm at the point where I…
GregRousell
  • 997
  • 2
  • 13
  • 23