Questions tagged [rgdal]

R Bindings for the Geospatial Data Abstraction Library

Filter by
Sorted by
Tagged with
0 votes
0 answers
25 views

ArcGIS Pro 3.1 errors out on lidR sf object Hulls exported as a polygon shapefile

So I am trying to write a Hulls object created from the crown_metrics function to a shapefile using st_write. Now, with st_write to resolve the 3D error in regards to a shapefile, I first used st_zm. ...
Arthur_Morgan's user avatar
0 votes
0 answers
91 views

read_osm from tmap package gives transformation error

I try to read Open Street Map data as shown in the RDocumentation of the tmap package. library(tmap) library(tmaptools) data(NLD_muni) osm_NLD <- read_osm(NLD_muni, ext=1.1) But I get following ...
sfetan's user avatar
  • 161
0 votes
1 answer
335 views

Error: unexpected string constant in

I'm trying to create a SpatialPointsDataFrame, however I get the error Error: unexpected string constant in: "NET.TO.EXTRAC_1 = SpatialPointsDataFrame(coords = net[,3:2], data = net, proj4string ...
Camila Valdés Cardona's user avatar
1 vote
2 answers
2k views

Using a downloaded shapefile in ggplot2 and R, readOGR error

I am having trouble taking a downloaded shapefile and using it in R and {ggplot2}. The online instructions (like this one) use code that have the function readOGR(). When I use readOGR(), I get ...
Michaela's user avatar
1 vote
1 answer
60 views

Plotting CALIPSO data in R

I am trying to plot one subdataset of CALIPSO which is in hdf format using R. The data is totally new to me as it's LiDAR data. I am not able to understand how to plot a graph between backscatter ...
shravani banerjee's user avatar
5 votes
2 answers
7k views

Fast way to convert raster to polygon shapefile in R

I have a single-band raster showing different land cover classes. I want to convert it to a polygon shapefile. I tried to use the rasterToPolygons function with the option to dissolve neighboring ...
Alemex's user avatar
  • 73
0 votes
0 answers
89 views

How to intersect shapefile with polygons in R properly?

I have a WI shapefile (https://data-wi-dnr.opendata.arcgis.com/datasets/wi-dnr::wisconsin-state-boundary-24k/explore?location=44.747223%2C-89.836300%2C8.20) and a grid that I want to intersect so that ...
user8229029's user avatar
1 vote
0 answers
29 views

What (if any) coordinate systems can be used so that distances can be calculated from coordinates?

I am trying to do some work that involves spatiotemporal latent surface modeling, but an issue that I am worried about is that calculating distance between two coordinates is quite a bit more ...
ctesta01's user avatar
  • 111
2 votes
1 answer
264 views

Plot a tidy map of English regions

I'm trying to plot a tidy map of English regions in R. I'm using code that runs successfully on other shapefiles, but when I run this the code executes without error, but then just presents a blank ...
Tom Wagstaff's user avatar
0 votes
1 answer
169 views

Merging .tif files via gdalbuildvrt not working

I have a piece of code in R that I have used for a while now to transform .xyz files to .tif and then merge all those .tif files into one big .tif. It has worked well when I last used it 2 years ago, ...
Bianca Piper's user avatar
0 votes
1 answer
682 views

Changing spatialpolygonsdataframe to default longitude/latitude (degrees) using R

I am trying (and failing) to convert the coordinates in a spatial object (Spatialpolygonsdataframe) form easting/northing to latitude/longitude. The zone is 35S. I know it can be achieved with ...
rratnaya's user avatar
1 vote
1 answer
1k views

Read geo-spatial data in R via Leaflet

I have some site boundary data as follow: UNB_BDSB_SiBdry_v08_201028lico_25831.cpq UNB_BDSB_SiBdry_v08_201028lico_25831.dbf UNB_BDSB_SiBdry_v08_201028lico_25831.prj ...
Haribo's user avatar
  • 115
0 votes
2 answers
281 views

rgdal setting unreliable in parallel raster processing - terra produces auxiliary files for wrapped rasters but not for locally defined ones

Background: When writing rasters using formats that do not support geolocation (for example .png), the Terra package saves auxiliary files containing this information. This can be prevented by ...
Smerla's user avatar
  • 390
0 votes
0 answers
957 views

Cannot open TIFF due to missing codec in R w/ raster library

Title explains my predicament. I cannot open a tiff file using the raster package and receive an error that tells me it is due to a missing codec: Code: library(rgdal) library(raster) file_name &...
Eric Romero's user avatar
0 votes
0 answers
554 views

projectRaster() error messages

This code worked perfectly fine for me a few months ago, but now I am receiving error messages. I've tried it two different ways. Has the projectRaster() function been deprecated or syntax changed? ...
Arden's user avatar
  • 1
0 votes
0 answers
96 views

Gdalwarp for terrain correction in SAR image

I am new to the gdal utility. Using DEM data of the Moon, I am trying to perform terrain correction on SAR images. Here is gdal commandline code ``` !gdalwarp -multi -wo NUM_THREADS=ALL_CPUS -co ...
Nidhi Verma's user avatar
0 votes
1 answer
528 views

Set RasterStack and SpatialPolygonsDataFrame to same coordinate system in R

I have a shapefile of 8094 Italian municipalities which I imported into R as a SpatialPolygonsDataFrame using readOGR. When I plot this, I get the following map: I also have a RasterStack of global ...
Charlotte's user avatar
3 votes
1 answer
586 views

How to test whether the argument passed to an R function is a raster or a vector

I am writing a function that expects two arguments: X and Y. Argument X should be a raster which can be generated by packages such as raster, terra, or stars. Argument Y should be a polygon from ...
Faustin Gashakamba's user avatar
1 vote
0 answers
41 views

Getting error while linking GDAL on MacOS 11.6 [closed]

(base) sushil@MacbookPro ~ % brew link gdal Linking /usr/local/Cellar/gdal/3.3.2_3... Error: Permission denied @ dir_s_mkdir - /usr/local/lib/python3.9/site-packages/GDAL-3.3.2-py3.9.egg-info (base) ...
sushil's user avatar
  • 11
2 votes
1 answer
501 views

Checking whether CRS is geographic coordinate system or projected coordinate system using R

I am writing a generic script that would calculate areas covered by different classes in a categorical raster in R. I would like to provide two functions; one for use when the CRS of the raster is ...
Faustin Gashakamba's user avatar
0 votes
1 answer
919 views

Unable to sum raster files in R using raster package

I am trying to sum all of my raster files (over 500) from a single folder in R, using the raster package, but am encountering an error message I cannot figure out how to solve. I am trying to use to ...
LostinSpatialAnalysis's user avatar
1 vote
2 answers
599 views

Split a huge .jp2 file into GeoTIFF tiles using R

I have the 2018 orthophoto of Luxembourg (RGB IR, entire country, 25 GB) and it is way too large to work with. Furthermore, it is in .jp2 format. I want to translate it into smaller GeoTIFF tiles, ...
Manuel Popp's user avatar
0 votes
0 answers
213 views

Overlapping two maps and extracting the mean value from overlapped range in R

I want to overlap a species distribution range on the world map which has values, and extract the mean value within the species range. I have 1500+ species distribution range in a gdb file so I try ...
CTY's user avatar
  • 1
1 vote
1 answer
4k views

Raster subset error in R: "Error: object of type 'S4' is not subsettable"

I am running this code in R: country_template <- raster() dimensions <- extent(124000, 463000, 2953600, 3127600) country_template <- setExtent(country_template, dimensions) res(...
user8160648's user avatar
1 vote
1 answer
1k views

projectraster in R cannot complete transformation

I have a few .tif rasters (ELEV and POP) projected in long/lat, but I would like the CRS and extent to be the same as a shapefile I have (STUDYAREA), for example, my study area lies mostly in UTM16 so ...
Beardedant's user avatar
2 votes
1 answer
2k views

Creating adjacent matrix with polygons in shapefile with R

I´m very new at these geospatial data analysis and manipulation in R. Right now I have a shapefile that you can find here: http://sina.conagua.gob.mx/sina/tema.php?tema=cuencas&ver=mapa&o=0&...
Paula Langle Tamayo's user avatar
-1 votes
1 answer
354 views

".shp" extension missing in R while other layers are present

I am trying to read a shapefile in R using the command: rivnet <- readOGR(dsn = 'sa_riv_30s',layer = 'sa_riv_30s') However, the '.shp' layer does not seem to be recognized by R. The layers present ...
sharsid94's user avatar
0 votes
1 answer
1k views

How do I get a raster layer containing cell centroid coordinates (x,y) of another raster using R?

I have a rasterStack object in R and a set of polygons that represent different landcover classes in that area. For all the cells that fall in those polygons, I have extracted pixel values for each ...
Faustin Gashakamba's user avatar
0 votes
1 answer
301 views

read_sf is truncating/rounding coordinates

I am using this function read_sf from package sf to read a shapefile in CRS 'ETRS89 / UTM zone 29N'. But coordinates are rounded to the meter after reading it. Trying to make a reproducible example I ...
gacero's user avatar
  • 123
1 vote
0 answers
418 views

Getting a rasterized object from irregular lat and long data

I have a dataframe (I've named it ozone2raster) with latitude and longitude points, and values for ozone concentration that I want to use for making a rasterized map. The dimensions of this dataframe ...
Matt's user avatar
  • 11
1 vote
1 answer
1k views

Error in writeOGR when trying to export spatial polygons as shapefile in R

I am trying to export polygons that i have created for home range data but when i go to export them get this error message: Error in writeOGR(colkud95[1, ], ".", "colonyhomerange", ...
Courtney's user avatar
1 vote
1 answer
716 views

Converting a SpatialPointsDataFrame into km units from m, in R

I read in a UTM shapefile to R using readOGR. I want to use the resulting SpatialPointsDataFrame to build a mesh in the INLA package, but I've been told that to help with numerical stability, I should ...
Michael Smith's user avatar
0 votes
1 answer
427 views

How to merge (mosaic) images that have some similar parts in their file names in R

I have multiple GeoTIFF files each representing a single tile of MOD13A3 NDVI data. My study area is covered by 2 tiles and I have a time series spanning 60 months. I want to mosaic(merge) every two ...
Faustin Gashakamba's user avatar
1 vote
1 answer
105 views

R: Should I transform my Raster to spatial objects here?

This question is a follow-up based on some of the advice provided in the answers and comments at Converting raster to spatial points without loss of information in R. First, to provide a bit of ...
MODIS Help please's user avatar
2 votes
1 answer
298 views

How do I change extent of shapefile into lat lon of NetCDF file?

I have loaded a shapefile and NetCDF into R, and I want to extract data based on the extent of the shapefile. I have done the following, but when I want to extract it I get NA's as the extent differs ...
Thomas's user avatar
  • 915
1 vote
1 answer
264 views

Create new polygon files from existing vector layer in R

I have an existing vector shapefile with all the counties in the United States (called counties.shp) I also have a dataset that contains many species-county presence data points (species.csv) which ...
pfadenhw's user avatar
2 votes
1 answer
2k views

Error importing TIFF file using raster in R: "Failure during raster IO"

I've been trying to import a TIFF formatted raster image into R using the raster::raster() function with no luck, and I would like to know if the file is corrupted, or if there is something I am ...
Dan Kennedy's user avatar
0 votes
1 answer
128 views

Eurostat shapefiles plotting with errors

I am trying to plot interactive maps at the NUTS3 level. Initially I was using shapefiles that I constructed myself for the data in QGIS, however, when I tried to use them in R they rendered poorly ...
NateTillern's user avatar
3 votes
1 answer
314 views

error running readLAS() in lidR: 'new_proj_and_gdal' is not an exported object from 'namespace:rgdal'

I've just updated lidR to 3.1.1 and am now unable to load a .las file using readLAS(): las <- lidR::readLAS(paste(sfm_dir,"/","...
mikealonzo47's user avatar
1 vote
0 answers
28 views

Proper way to assign CRS in rgdal 1.5-23 [duplicate]

Perhaps my question has been already answered but if it did, I haven´t be able to find it. I´ve updated the rgal package to version 1.5-23 (GDAL 3.2.1 & PROJ 7.2.1) and when I run the following ...
Juan Carlos's user avatar
0 votes
2 answers
3k views

ogrListLayers cannot open data source

I recently updated R and all of it's packages, and my code for reading in the layers of a geodatabase no longer works. It works fine on my windows desktop, but doesn't work on my macbook (I change the ...
canderson156's user avatar
2 votes
1 answer
501 views

Subscript out of bounds error while mosaicking TIFFs together

I have just downloaded NDVI imagery from Google Earth Engine. The image was too big so it was divided into about 35 .tif files. Each tile has approximately 950 bands of NDVI values. I am now trying to ...
Douglas's user avatar
  • 425
1 vote
0 answers
98 views

Is it better to calculate area of a global raster using long/lat or using an equal area projection (e.g. Galls-Peters)?

I am trying to calculate the area of values in a global spanning raster with values of NA, 1, 2 or 3. I would like to know the total area of each category, however, the map is currently in lat long (...
Jakey's user avatar
  • 21
1 vote
1 answer
1k views

Unable to library "rgdal" and "gdalUtils" after upgrading to macOS big sur

I just upgraded my laptop to macOS big sur, but then I could not library "rgdal" and "gdalUtils". It threw me an error: Error: package or namespace load failed for ‘rgdal’ in dyn....
Liam Zhong's user avatar
1 vote
1 answer
5k views

Unable to find inherited method for function ‘crop’ for signature ‘"numeric" using R

I'm trying to iterate a crop and then a resampling process by using a for loop but I've faced some problems because I'd obtain an error message. Below is my code, then the error message #find all tifs ...
Judá García's user avatar
1 vote
1 answer
755 views

Reading or creating empty shapefile in R

I have several polygon shapefiles that I need to merge into one using a loop in R. I want to start with an empty shapefile and merge it with the existing shapefiles. All shapefiles will be chacked ...
Ilik's user avatar
  • 13
2 votes
2 answers
2k views

How to convert MTM coordinates to WGS84 with R?

I have MTM coordinates in the following format df <- data.frame(xcentro = c(250605,250770,250871),ycentro = c(5186087,5185610,5186140)) and need them to be converted in the WGS84 format. I expect ...
Xavier Prudent's user avatar
0 votes
0 answers
87 views

Are these sp files equal in terms of proj4string? Can I do some transformation of the proj4string?

summary(SCat_sp_E6) Object of class SpatialPolygonsDataFrame Coordinates: min max x -74.095072 -74.018988 y 4.647323 4.832934 Is projected: FALSE proj4string : [+proj=longlat +...
LACL's user avatar
  • 1
8 votes
4 answers
2k views

sp::proj4string equivalent in the PROJ6 framework?

I am confused about the shift from PROJ4 to PROJ6 in the (relatively) recent versions of the spatial packages of R (and gdal for that matter). I used to use sp::proj4string() to get the projection ...
Mikko's user avatar
  • 374
1 vote
1 answer
612 views

Reprojecting GOES-16 data in R

I'm trying to plot GOES-16 data with world boundaries. Data comes from GOES-16 files such as this. Data comes with "GOES-R ABI fixed grid projection" reference system, which to my better ...
Ubron Cinzento's user avatar

1
2 3 4 5