Skip to content
Gilles San Martin edited this page Mar 11, 2019 · 8 revisions
sp command sf command
disaggregate st_cast
plot(x) plot(st_geometry(x))
coordinates(x) st_coordinates(x)
coordinates(x)=~x+y st_as_sf(x, coords = c("x","y"))
over(x,y,returnList=TRUE) st_intersects(x,y)
over(x,y) sapply(st_intersects(x,y), function(z) if (length(z)==0) NA_integer_ else z[1])
spDists(x,y) st_distance(x,y)
aggregate(x,by,mean,areaWeighted = TRUE) st_interpolate_aw(x,by,mean)
merge(x,y) merge(x,y)
CRS(projargs) st_crs(proj4string)
proj4string(x) st_crs(x)
proj4string(x) <- p4s st_crs(x) <- p4s or st_set_crs(x, p4s)
spTransform(x, CRSobj) st_transform(x, crs)
bbox(x) st_bbox(x) or matrix(st_bbox(x), 2) to get the same output as bbox
x@data st_set_geometry(x, NULL) or st_drop_geometry(x)

Full list of commands, exported by sp:

sp command sf command
addAttrToGeom st_sf
areaSpatialGrid *
as.character.DMS
as.double.DMS
as.image.SpatialGridDataFrame *
as.numeric.DMS
as.SpatialLines.SLDF st_geometry
as.SpatialPolygons.GridTopology see st_make_grid
as.SpatialPolygons.PolygonsList -
bbexpand
bbox st_bbox
bpy.colors sf.colors
bubble see plot, use pararameter cex
cbind.Spatial cbind
char2dms
compassRose
coordinates for POINT: do.call(rbind, st_geometry(x))
coordinates<- see arg coords in st_as_sf, or st_set_geometry
coordinatevalues *
coordnames * (in sf, coordinates are unnamed)
coordnames<- -
CRS st_crs
dd2dms
degAxis (integrated)
degreeLabelsEW (integrated)
degreeLabelsNS (integrated)
dimensions see class(x) with x an sfg, geometry object; this is not similar to st_dimensions!
disaggregate see st_cast
flipHorizontal
flipVertical
fullgrid *
fullgrid<- *
geometry st_geometry
geometry<- st_geometry<-
get_col_regions -
getGridIndex *
getGridTopology *
getLinesIDSlot -
getLinesLinesSlot -
get_ll_TOL
get_ll_warn
getPolygonAreaSlot -
getPolygonCoordsSlot -
getPolygonHoleSlot -
getPolygonLabptSlot -
getPolygonsIDSlot -
getPolygonsLabptSlot -
getPolygonsplotOrderSlot -
getPolygonsPolygonsSlot -
get_Polypath -
get_PolypathRule -
get_ReplCRS_warn
gridat
gridded *
gridded<- *
gridIndex2nb *
gridlines *
gridparameters *
GridTopology *
HexPoints2SpatialPolygons
identicalCRS == method for crs objects
IDvaluesGridTopology *
IDvaluesSpatialPixels *
image2Grid *
imageScale *
is.projected(x) !st_is_longlat(x)
layout.north.arrow
layout.scale.bar
Line see st_line
LineLength see st_length
Lines -
LinesLength see st_length
longlat.scales
makegrid *
mapasp
mapLegendGrob
merge merge
over see st_intersects
%over% see st_intersects
panel.ggmap -
panel.gridplot -
panel.pointsplot -
panel.polygonsplot -
panel.RgoogleMaps -
plot plot
point.in.polygon
points2grid *
Polygon see st_polygon, st_multipolygon
polygons st_geometry
polygons<- st_set_geometry
Polygons -
print.DMS
proj4string st_crs
proj4string<- st_set_crs
rbind.SpatialLines rbind
rbind.SpatialLinesDataFrame rbind
rbind.SpatialMultiPoints rbind
rbind.SpatialMultiPointsDataFrame rbind
rbind.SpatialPixels rbind
rbind.SpatialPixelsDataFrame rbind
rbind.SpatialPoints rbind
rbind.SpatialPointsDataFrame rbind
rbind.SpatialPolygons rbind
rbind.SpatialPolygonsDataFrame rbind
read.asciigrid see st_read
recenter
remove.duplicates see st_union on multipoint
select.spatial
set_ll_TOL
set_ll_warn
set_Polypath
set_PolypathRule
set_ReplCRS_warn
Spatial
SpatialGrid *
SpatialGridDataFrame *
SpatialLines see st_sfc
SpatialLinesDataFrame see st_sf
SpatialLinesLengths see st_length
SpatialMultiPoints see st_sfc
SpatialMultiPointsDataFrame see st_sf
SpatialPixels *
SpatialPixelsDataFrame *
SpatialPoints see st_sfc
SpatialPointsDataFrame see st_sf
SpatialPolygons see st_sfc
SpatialPolygonsDataFrame see st_sf
SpatialPolygonsRescale see st_sf
spChFIDs -
spChFIDs<- -
spDists st_distance
spDistsN1 see st_distance
sp.grid -
sp.lines -
split split?
spmap.to.lev -
sppanel -
sp.panel.layout -
spplot plot, ggplot
spplot.key -
spplot.locator -
sp.points -
sp.polygons -
spsample st_sample, st_line_sample (partial support)
sp.text -
sp.theme -
spTransform st_transform
summary summary
surfaceArea -
write.asciigrid see st_write
zerodist
zerodist2

* concerns gridded/raster data, not supported by sf

- irrelevant

relevant commands, exported by rgeos

rgeos command sf command
gArea st_area
gBinarySTRtreeQuery
gBoundary st_boundary
gBuffer st_buffer
gCentroid st_centroid
gContains st_contains
gContainsProperly st_contains_properly
gConvexHull st_convex_hull
gCoveredBy st_covered_by
gCovers st_covers
gCrosses st_crosses
gDelaunayTriangulation st_triangulate
gDifference st_difference
gDisjoint st_disjoint
gDistance st_distance
gEnvelope
gEquals st_equals
gEqualsExact st_equals_exact
getScale st_precision, st_set_precision
gInterpolate see st_line_sample
gIntersection st_intersection
gIntersects st_intersects
gIsEmpty st_is_empty
gIsRing
gIsSimple st_is_simple
gIsValid st_is_valid
gLength st_length
gLineMerge st_line_merge
gNearestPoints st_nearest_points
gNode st_node
gOverlaps st_overlaps
gPointOnSurface
gPolygonize st_polygonize
gProject
gRelate st_relate
gSimplify st_simplify
gSymdifference st_sym_difference
gTouches st_touches
gUnarySTRtreeQuery
gUnaryUnion aggregate
gUnion st_union
gWithin st_within
gWithinDistance st_within
readWKT st_as_sf
setScale st_precision, st_set_precision
version_GEOS sf::sf_extSoftVersion()["GEOS"]
version_GEOS0
writeWKT st_as_text

relevant (non-raster) commands, exported by rgdal

rgdal command sf command
checkCRSArgs st_crs
CRSargs st_crs
get_OVERRIDE_PROJ_DATUM_WITH_TOWGS84
getPROJ4libPath
getPROJ4VersionInfo
llgridlines st_graticule
make_EPSG
ogrDrivers st_drivers
ogrFIDs
ogrInfo print
ogrListLayers st_layers
OGRSpatialRef st_crs
project st_transform
projInfo st_proj_info
projNAD
rawTransform
readOGR st_read, read_sf
RGB2PCT
setCPLConfigOption see argument options of st_read
set_OVERRIDE_PROJ_DATUM_WITH_TOWGS84
showEPSG st_crs
showP4
showWKT st_as_text(crs)
writeOGR st_write, write_sf