Questions tagged [spatial-data-frame]
51 questions
6
votes
1 answer
How can I transform a SF object into a Spatial Points Data Frame?
I'm currently trying to map all the zip codes in North Carolina onto a leaflet map. Ultimately, I'd like to color-code these with values from another data-set.
While I've managed to put markers onto the map with these values, doing so in a colorized…

seabass20
- 227
- 3
- 14
5
votes
1 answer
How do I extract raster values from polygon data then join into spatial data frame?
I would like to merge polygon data and raster data into one dataframe for purposes of then using randomForests package in R.
This involves first extracting the mean raster value per polygon.
So far, I have the following:
#load…

user3251223
- 265
- 1
- 7
- 15
4
votes
1 answer
Creating data objects for interpolation methods such as kriging in R
I have daily meanvalues of temperature data at different locations (X1, X2, ...) and I would like to interpolate maps with them.
I created a long format data objects by loading them from formatted excel sheets such as:
library(reshape2)
tempdata…

MojioMS
- 1,583
- 4
- 17
- 42
3
votes
4 answers
Join two columns into one in a SpatialDataFrame, but omitting NAs In R
I'm trying to join two columns of a SpatialDataFrame (shapefile) into one using the R program, but in both columns there are empty spaces, when they are together with the name plus NA, however I would like the NAs not to appear in my new column. I…

Kledson Lemes
- 75
- 7
3
votes
1 answer
Subset Spatial Points to Extract those inside of a Polygon (Countries Borders)
I have a data.frame with lat long coordinates:
df<-data.frame(
lat=c(40, 30, 40.864),
lon=c(0, 20, 1.274)
)
And the border of a country (Spain),
library(raster)
border <- getData("GADM",country="Spain",level=0)
I would like to select…

Javi_VM
- 505
- 2
- 10
2
votes
0 answers
Combining 2 raster data sets with different extent, resolution and point regularity
I'm having trouble merging two raster datasets that have different resolution and extent, and have irregular point data. Below is info on each raster. I need these datasets to merge according to the grid points so that I can run a fire spread model…

Sarah
- 21
- 1
2
votes
1 answer
R - combine character and numeric columns in SpatialPolygonsDataFrame
I would like to find an efficient way to combine certain character + numeric column values in a list of SpatialPolygonsDataFrame objects. Here is reproducible data:
library(maptools) ## For wrld_simpl
library(sp)
## Example…

Dorothy
- 523
- 1
- 5
- 17
2
votes
1 answer
Creating spatialpolygons dataframe from list of polygons
I am currently trying to create a polygon shapefile from a list of polygons (study areas for biodiversity research).
Currently these polygons are stored in a list in this format:
$SEW22
[,1] [,2]
[1,] 427260.4 5879458
[2,] 427161.4…

S.K.
- 157
- 2
- 10
2
votes
2 answers
Convert a raster to a dataframe and extract values you want in R
I want to make a bathymetry map using ggplot2. I converted a raster file to a data frame, clopped and converted it to a dataframe:
library(raster)
##Import a raster file
Bathymetry_dat <- raster("w001000.adf")
##Clop the raster file
Bathy_clopped…

Young
- 47
- 2
- 9
2
votes
1 answer
mapping by ggplot2 geom_polygon goes crazy after merging data
I am trying to make a grid containing maps of megaregions in the us. I create a SpatialPolygonDataframe from a shape file. then convert it into a data.frame to use ggplot2. as soon as I add the data into the frame, the polygon plots.
the file…

BobbyF
- 431
- 1
- 7
- 19
2
votes
2 answers
unable to plot two spatial objects with identical CRS in R
I have two spatial objects, one is a spatial polygon object and the other one is a .csv file that I turned into a spatial points object. The first one is an official shape file from the chilean government for one of its communes, the other one was…

csmontt
- 614
- 8
- 15
2
votes
1 answer
Error in Plotting Longitude Latitude with Fill Values in ggplot2
I have a data with longitude, latitude and value at each grid. A grid may have more than one value so I set alpha to visualize multiple values. My aim is to fill grids with three different ranges. If the value is zero then that grid would be empty.…

Pankaj
- 1,296
- 2
- 13
- 23
2
votes
1 answer
Python Pandas: Spread total values in dataframe based on percentages back to categories
I have the below dataframe and I would like to spread the total values in the val columns back to the Cat column based on the percentages in the Percentage column.
Country State City Cat Total amount Percentage val1 val2 val3 …

Indole
- 45
- 1
- 1
- 6
2
votes
2 answers
Assign and use data values of Spatial*DataFrame easily
Is it possible to somehow easily work with data in Spatial*DataFrame (* = Points, Lines, Polygons, Pixels, Grid,...)? In particular I have difficulties with assigning values to it and to operate with…

Tomas
- 57,621
- 49
- 238
- 373
1
vote
1 answer
include simple features attributes in a sfnetwork graph
I'm working with a .shp file with LINESTRING geometry and for each line there are several attributes.
Simple feature collection with 5979 features and 39 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: 334297 ymin: 6277095…

mrR
- 11
- 1