Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [r-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.

0 votes
1 answer
20 views

How to group aggregate data based of latitude and longitude

I have 2 dataframes in R that both have this type of structure: Lon Lat Measurement 5 7 15 5 8 20 The numbers in the actual dataframes are different from this example but I don't think that should ...
s.eyal's user avatar
  • 33
2 votes
1 answer
34 views

Coalescing two `POINT` columns gives a list-column instead of another `POINT` column

I have two tibbles, each with a geometry column. I want to merge those and make a sort of coalesce() but if I combine ifelse() with st_is_empty() I end up with a list column instead of a POINT column: ...
bretauv's user avatar
  • 8,333
1 vote
1 answer
80 views

Issue projecting polygon that crosses dateline R

I have a polygon in a North America equal area projection and I would like to transform to unprojected long/lat. I would like to use it to crop a global raster in unprojected longlat. The problem is ...
Pascal's user avatar
  • 1,654
0 votes
1 answer
40 views

Tigris package produces error after R update: GDAL Error 1: PROJ: proj_identify: Cannot find proj.db

I recently updated R from 4.3.x to 4.4.1. I am now getting errors as follows: mystates <- tigris::states(cb = T) #> Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : ...
jzadra's user avatar
  • 4,174
2 votes
1 answer
64 views

R and ggplot with st_crop: map cropping does not work as wanted

I am trying to plot only a part of the world map, limited by a square with limits lon (-30, 90) and lat (30, 82). When I try to crop the map with sf_crop, it does not return the desired square when ...
SkiFlyer's user avatar
-1 votes
1 answer
72 views

Misaligned sf object in ggplot

I have two sf objects, which when plotting are slightly misaligned. While initially the two objects have different CRS: the first has: WGS 84 the second has: MGI / Austria GK East I proceed, as ...
Tom's user avatar
  • 23
1 vote
1 answer
37 views

I would like to identify the primary administrative unit from the latitude and longitude coded in the dataset

I want to identify the primary administrative unit from the latitude and longitude coded in the dataset, and fill that administrative unit with red What I tried: library(rnaturalearth) library(sf) ...
新子泰平's user avatar
0 votes
1 answer
37 views

`purrr` mapping of `st_intersects()` using inputs from across two lists

I have a list of geocoded point dataframes that I want to intersect with a corresponding list of polygon geometry dataframes. Below is a reprex to create the data structure: library(dplyr) library(...
Scott's user avatar
  • 313
2 votes
1 answer
35 views

Rotating/angle of ggplot key_glpyh, custom legend key glyph

I am trying to emulate a plot style ive seen online, created by Chris Canipe (https://www.axios.com/2017/12/15/the-flow-of-goods-between-states-1513304375). Looking at trade flows, I've managed to ...
Rupert Stacy's user avatar
0 votes
0 answers
53 views

How to create a 'count' choropleth map? Large dataframe with many different values overlain on separate geodatabase

I am aiming to plot a choropleth map (plotted using the polygons from a geodatabase) that will count the number of instances per region (wildlife management units) from a separate data frame (...
Flavia Rasmussen's user avatar
0 votes
1 answer
68 views

Removing white border plotting maps with geom_sf

I am attempting to remove the white borders around a facet plot that I created with geom_sf(). Previously I was using the now deprecated rgdal package and coord_cartesian(). I am trying to get a ...
Tim Van Der Stap's user avatar
0 votes
1 answer
57 views

Transform point into UTM 32N

i am coding with R and RStudio. I have a set of polygons in one in my global environment called buek250_shapefile. I am able to plot them with leaflet. For the next step I wrote a function which gets ...
odcoder's user avatar
0 votes
1 answer
99 views

Merge two shapefiles in R, get a dataframe of variable value in each precinct

I'm not a GIS person, this is driving me nuts. I have a shp file of voting precincts. I have another shp file of radio broadcasts. I want to use R to geolocate the broadcasts into the precincts, so ...
user1060859's user avatar
0 votes
1 answer
74 views

I need spatial polygons representing the land and sea in a world map and then convert them to a dataframe

I need a world map in R that can be transformed into polygons of land to be able to calculate distances through sea from one point to another and going around land/polygons. These polygons need to be ...
Iris Van Paemel's user avatar
1 vote
2 answers
79 views

Filter polygons on coordinates

I'm currently working with a shapefile that does not contain explicit latitude and longitude coordinates. My goal is to filter out areas with latitudes above 60 degrees. I want to delete the small ...
Amy Xiejing's user avatar
3 votes
1 answer
73 views

Trying to create continent map for South America but geom_polygon produces zigzag fill

I try to do this ggplot: library (sf) library(dplyr) library(ggplot2) continents.f.xy <- st_zm(continents.f) continents_map_SA <- continents.f.xy%>% dplyr::bind_rows() %>% #bind the ...
Leprechault's user avatar
  • 1,707
1 vote
3 answers
68 views

Customize malaria atlas project autoplots

I am trying to plot some data from the Malaria Atlas Project. Therefore, I looked in the vignette and used an example for getting started: if (!require("malariaAtlas")) install.packages(&...
Excelsior's user avatar
  • 181
3 votes
2 answers
129 views

R: How to replace values in polygon geometry without a for loop?

I have over 60,000 building polygons footprints in shapefile format (polygonZ) where I need to replace the z values (for each ring) for all the polygon vertices, so that all the Z values for the ...
nola's user avatar
  • 45
1 vote
1 answer
81 views

adehabitatHR KUD loop not overlaying mapping correctly in R

I have some code which calculates KUD at 95% from fish position data, restricted by the bounds of a shapefile, and then plots this, and overlays the shapefile on top. ########## BOUND KUD TO SHAPEFILE ...
mikejwilliamson's user avatar
0 votes
1 answer
56 views

Downloaded sf polygon data are not visible on plotted map

I´m trying to create a range map in R, which is supposed to show the occurrences of a specific tree species (Quercus cerris) in the world. For this, I use the BIEN database and the function ...
user23632192's user avatar
0 votes
1 answer
99 views

Draw data ellipses at spatial locations

I have a data objects that contains a sample of measurements obtained for two air pollutants at a series of monitoring stations. I also have the spatial coordinates of these stations. For example: ...
agila's user avatar
  • 3,630
0 votes
1 answer
69 views

Longitude and latitude data not generating correct polygons using maps/mapdata/ggplot2 packages

I am trying to draw a map for all province within Egypt using maps and ggplot2 package in R, but I did not find any sub-region (provinces) for Egypt available in the databases of these packages. So, I ...
Mohamed Samir's user avatar
0 votes
1 answer
78 views

How to match the coordinates of 2 shapefiles in R

I have 2 shapefiles, one of them has the coordinates of administrative units as a multipolygon, and the other has the coordinates of various sections of a border wall as a multilinestring. I am trying ...
user24939654's user avatar
2 votes
1 answer
83 views

How to adjust population data in a raster dataset using census data from an administrative boundary shapefile

I downloaded 100m resolution population raster data from WorldPop, and through transprojection and cropping, I got a city's population spatial distribution raster data, in addition, I have the ...
Wei Liao's user avatar
1 vote
2 answers
92 views

R: Weighted mean is 0 for buffers that have no data

I am a newbie at R and am having trouble figuring this issue out so any help would be appreciated. I have daily flooding raster data that I am using to calculate the weighted mean of flooding in ...
Iris Iris's user avatar
0 votes
1 answer
97 views

Z coordinates are missing in sfc geometry in R

i'm literally new in programming and R. I have set of street networks and the segments of each network has been exploded by using QGIS. After using st_read, I found that the type of geometry of my sfc ...
Daksa Lintang's user avatar
0 votes
1 answer
68 views

What is returned by st_coordinates?

I am in the process of converting R scripts to Python and there are multiple uses of st_coordinates. I know that geopandas has similar functionality in get_coordinates, but st_coordinates apparently ...
wannabeengineer15's user avatar
1 vote
1 answer
104 views

Incorrect results when intersecting point and polygon data with sf in R

I’m getting bizarre results when I intersect some point data with polygons using the sf package in R, and while I think I’ve found a solution, I’m so baffled by the issue that I’d really appreciate it ...
dmcd's user avatar
  • 135
2 votes
1 answer
77 views

How to show both colors at a border using geom_sf?

I'm creating a map with two layers- a heatmap (geom_tile) with biome data and layering a map of the different regions on top. I've got a list countries in each region and I got R to display a map with ...
Jordan T's user avatar
3 votes
1 answer
110 views

Is there a way to completely snap a linestring to polygon in R?

I have 2 SHP files, one with many linestrings (railroads) and one with many polygons (counties in the U.S.). There is no intersections between those two files at all. My goal is to snap the lines to ...
Roee Diler's user avatar

15 30 50 per page
1
2 3 4 5
67