Questions tagged [r-sp]

An R package for spatial data. Questions on spatial data might be better asked on https://gis.stackexchange.com

691 questions
6
votes
2 answers

r gis: identify inner borders between polygons with sf

This is an update of my previous similar question, the same task only I need to do it within sf framework. I need to identify the inner boundaries between polygons, red lines in this map. Within sp framework I used to utilize a self written…
ikashnitsky
  • 2,941
  • 1
  • 25
  • 43
6
votes
1 answer

how to crop raster based on SpatialPolygons in R

I would like to crop a raster based on SpatialPolygons object. I know that we can use crop function in raster package, raster::crop(rasterFile, SpatialPolygonsObject) but this function is based on the extent of SpatialPolygons object, so the…
just_rookie
  • 873
  • 12
  • 33
6
votes
3 answers

portion of a raster cell covered by one or more polygons: is there a faster way to do this (in R)?

Pictures are better than words, so please have a look at What I have is a RasterLayer object (filled with random values here for illustration purposes only, the actual values don't matter) a SpatialPolygons object with lots and lots of polygons…
Where's my towel
  • 561
  • 2
  • 12
6
votes
1 answer

Heat map of Germany using spplot

I was working on heat map of Germany using spplot, I had the shape file from GADM German shape file Level 1 http://biogeo.ucdavis.edu/data/gadm2.8/rds/DEU_adm1.rds I am able to make the heatmap but i suppose the maps are getting wrongly plotted, as…
PSraj
  • 229
  • 4
  • 10
6
votes
0 answers

Merge / Dissolve small polygons by size using R

I converted a raster with 4 classes to a SpatialPolygonsDataFrame, where the features representing a class are not always connected. I used disaggregate (package sp) to get single features. I now want to get rid of all those features, smaller than…
Blake
  • 101
  • 1
  • 4
5
votes
1 answer

raster and polygons in leaflet, without raster interpolation

I'm trying to display several layers in leaflet (or mapview), one of which is a raster in EPSG:27700. The only way I manage to adequately overlay those layers is through the default latlong projection, which implies a reprojection of the raster and…
5
votes
1 answer

guess coordinate system from x and y in meters, and approximate corresponding long and lat

I have this data frame of coordinates of Belgian locations : data # # A tibble: 11 x 4 # LON LAT x y # # 1 3.618942 50.68165 96227.01 152551.2 # 2 3.473466 50.55899 86074.26…
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
5
votes
2 answers

How can I predict values for a specific point using the idw() function in R?

Using this answer from Ege Rubak as an example, how can I predict pH values for a specific point, say lat = -23.49184 and long = 152.07185, using the idw() function in R? The closest answer I found was through this document in RPubs, but I could not…
bbiasi
  • 1,549
  • 2
  • 15
  • 31
5
votes
1 answer

Change plotting order of categories of data in tmap map R

I am plotting some spatial data in R using the tmap package. I define breaks and plot color in the tm_dots function. I'd like to be able to define the plot order of the categories so that they are defined by the category (highest category on top,…
user29609
  • 1,991
  • 18
  • 22
5
votes
2 answers

Subset spatial points with a polygon

I have a SpatialPolygonsDataFrame (spolydf) and a SpatialPointsDataFrame (spointdf). The layers have different extents, but overlap. I can select points that fall within the polygon using fall.within.poly <- spointdf[spolydf,] How do I select…
user2175481
  • 147
  • 1
  • 8
5
votes
2 answers

For each point in one data set, calculate distance to nearest point in second data set

Trying to find, for each point in a SpatialPointsDataFrame, the distance to the closest point in a second SpatialPointsDataFrame (equivalent to the "nearest" tool in ArcGIS for two SpatialPointDataFrames). I can do the naive implementation by…
nick_eu
  • 3,541
  • 5
  • 24
  • 38
5
votes
1 answer

Change raster cell values to NA if cell contains a point

I have a number of raster layers contained in a single stack as well as a SpatialPoints object containing point coordinates. I am trying to change the value of the raster layers to NA if the cell contains a point. I have provided a reproducible…
B. Davis
  • 3,391
  • 5
  • 42
  • 78
5
votes
2 answers

How to add Hawaii and Alaska to spatial polygons in R?

How can I add Hawaii and Alaska to the following code (taken from Josh O'Brien's answer here: Latitude Longitude Coordinates to State Code in R)? library(sp) library(maps) library(maptools) # The single argument to this function, pointsDF, is a…
Adam Smith
  • 2,584
  • 2
  • 20
  • 34
4
votes
2 answers

Different outcomes from autokriging and manual kriging

Can someone help me understand why I am getting such different results from auto- and manual kriging? I see the two algorithms are using different variogram models, but is that alone the reason for all the discrepancy? I am also uncomfortable with…
Manojit
  • 611
  • 1
  • 8
  • 18
4
votes
1 answer

Convert DMS coordinates to decimal degrees in R

I have the following coordinates in DMS format. I need to convert them to decimal degrees. # Libraries > library(sp) > library(magrittr) # Latitide & Longitude as strings > lat <- '21d11m24.32s' > lng <- '104d38m26.88s' I tried: > lat_d <-…
Arturo Sbr
  • 5,567
  • 4
  • 38
  • 76
1 2
3
45 46