Questions tagged [spatial-data-frame]

50 questions
5
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
  • 187
  • 9
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
  • 235
  • 1
  • 5
  • 14
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,092
  • 2
  • 11
  • 31
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…
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
  • 393
  • 3
  • 14
2
votes
1 answer

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
  • 8
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
  • 291
  • 1
  • 5
  • 17
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
  • 564
  • 6
  • 14
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,094
  • 2
  • 12
  • 21
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
  • 5
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
  • 52,167
  • 46
  • 207
  • 345
1
vote
1 answer

How to specify tm_fill() if I want it to be a variable from a new object?

I am trying to create an R function that would run a GWR on variables that the user specifies from a Spatial Polygons Data Frame. The end result of running the function are two mappings - one of the independent variable's values and one of the…
1
vote
3 answers

In R, how do I reproject from the MODIS sinusoidal projection to latlong (ellps=WGS84) projection

I have managed to extract MODIS land cover data from an HDF file and put it into a raster. library(gdalUtils) #? gdal_translate? library(raster) sds <- get_subdatasets(".......myfileplath/file.hdf") # Isolate the name of the first sds name <-…
1
vote
0 answers

Transform a data frame into a spatial data frame to be able to get an ESRI shapefile to open in QGIS (R programming)

I have a data frame in R (no2df) it looks like this: **> head(no2df) id latb lonb lat lon no2tc 5028741 816834 32.95808 36.61589 33.00045 36.63499 3.276456e-05 5028742 816834 32.98067…
1
vote
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
  • 451
  • 2
  • 9
1
2 3 4