Questions tagged [sf]

The motivation behind the `sf` package is to provide a complete, standardized implementation of simple features in R, with links to GDAL, GEOS and Proj.4. There is a also https://gis.stackexchange.com/ for spatial R questions.

sf is a new R package for handling and analyzing spatial data in R. While various R packages are available that provide classes and methods for spatial data (e.g. sp, rgdal and rgeos), sf, which is developed by Edzer Pebesma and others, is intended to gradually replace the well known sp package. The motivation behind this package is to provide a complete, standardized implementation of simple features in R, with links to GDAL, GEOS and Proj.4.

1040 questions
0
votes
1 answer

Reading a shapefile and plot with geom_sf returns error

I wish to plot some maps of Denmark using the new sf package and geom_sf() from ggplot2. I have a shapefile from a public map service, with a total of 4 files (DK.shp, DK.dbf, DK.shf and DK.prj). I have made the data available here in a zip-file…
emiltb
  • 309
  • 3
  • 10
-1
votes
1 answer

shapefiles: convert Point (MultiPoint) to Point (PointZ) geometry in R

I have a shapefile (mult_point_example.shp) in a multipoint geometry: # Packages require(sf) # get AOI download.file( "https://github.com/Leprechault/trash/raw/main/mult_point_example.zip", zip_path <- tempfile(fileext =…
Leprechault
  • 581
  • 3
  • 15
-1
votes
1 answer

add a numeric variable from a data.frame object to an sf object containing multpolygons

I'm unable to add a numeric variable in a data frame object to an SF object containing polygons. So, I can't create my map with Ggplot2. Any help would be very appreciated... Thanks a lot Richard
-1
votes
1 answer

Opening shapefile with sf in r gives an error

I want to open a Shapefile in RStudio that is stored on my Mac. I have used the sf library and used the following code: shapeFile= st_read("/Users/roelalex/Desktop/testFolder/cb_2015_us_county_5m.shp") But then I get this error message: Error:…
-1
votes
1 answer

How to generate 10x10km grid cells of all countries?

Good morning, I am currently trying to get 10x10 (or 5x5) km grid cells of countries (no ocean) clipped to the borders. See for example a grid raster for Nigeria: Nigeria Grid Cells PLAN A: My plan was to take the GADM level 0 map…
Luca
  • 1
  • 2
-1
votes
1 answer

spatial projection issues - unknown datum GRS1980

I have two sf objects coming from different sources but supposed to represent the same polygon. However, when plotting them, they clearly appear shifted from one another: Reprojecting the objects does not seem to solve the problem, and I am…
Jo_
  • 59
  • 5
-1
votes
1 answer

Looking for a polygon where a point is contained in R

I'm working with a dataframe containing longitude and latitude for each point. I have a shapefile containing mutually exclusive polygons. I would like to find the index of the polygon it where each point is contained. Is there a specific function…
-1
votes
1 answer

Extracting points in sf object by attributes in R

I created an sf object from a point shapefile and would like to create a new object by choosing points with certain attributes only. In that case, only those points which have "Survey Start" in the column Subcategor. Shifting thinking from sp/rgdal…
MIH
  • 989
  • 1
  • 12
  • 23
-1
votes
1 answer

Reprojecting & CRS of Shapefile using sf Package in R

I am a new R user. I have a shapfile in R which I want to use to calculate the K nearest neighbor. Each polygon's centroid (Inside_X & Inside_Y) was calculated in arcmap (Example: X: 32570914 Y: 5791442). I used the sf package to get a CRS for my…
-1
votes
1 answer

R sf: Points of LinearRing do not form a closed linestring

I am trying to calculate the centroids of a set of polygons. My dataset, geodata, contains five columns including one geometry column of class sfc_GEOMETRY, with 45759 rows. When I run sf::st_centroid(geodata), I get the following message Error…
Ben Mann
  • 113
  • 1
  • 8
-1
votes
1 answer

Using GGPlot to plot spatial data and color based on a column value in R

Im reading in spatial data from a shapefile that contains the location of 100 districts in a province. In another dataframe, I have each districts population data. Im trying to use ggplot to create a map of the province (from the shapefile) and…
aport550
  • 79
  • 6
-1
votes
1 answer

Background images with sf maps and alternative crs

Is it possible to use a background image with sf map plots and also have the image be transformed with the coordinate reference system in use? For example, the first plot below is using the NASA night lights image with EPSG:4326. The second image is…
qwertytam
  • 51
  • 6
-1
votes
1 answer

Display by color groups of units in sf map

I have technical question for you : I have a shapfile of few cities in a district library(dplyr) library(ggplot2) library(sf) read_sf("cities.shp") %>% ggplot() + geom_sf() + theme_bw() My shp look like that : Code Name Long…
-1
votes
1 answer

How to extract the names of the layers from `sf::st_layers()`?

I would like to extract the layer name of a shapefile with the R {sf} package. I tried to extract informations from sf::st_layers(). i looked at the sf::st_read() but I wasn't able to see how it gets the layer name. st_layers(dsn =…
-1
votes
1 answer

About my GIS question in R (from readShapePoly to sf::st_read)

I am needed to use sf package command, because readShapePoly commnad will be erased. That's neer future I know... So I want to change my code from route thata readShapePloy to route sf::st_read. But I cannot write correct code. So I want to correct…
Mi_Jun
  • 39
  • 3
1 2 3
69
70