rgdal

How to convert NAD 83 coordinates to latitude and longitude with rgdal package?

二次信任 提交于 2019-12-21 11:29:20
问题 I have coordinates, all of which should be located in DC, but I cannot figure out how to convert them from NAD 83 to latitude and longitude in R. I'm using the spTransform() function in the rgdal package and get an error about non-conformant data. library(rgdal) nad83_coords <- data.frame(x=c(396842.6, 397886.9, 398315.5, 398154.3, 398010.3), y=c(140887.1, 139847.0, 138743.9, 139534.5, 138697.3)) coordinates(nad83_coords) <- c('x', 'y') proj4string(nad83_coords) <- CRS("+init=epsg:4269")

How to convert NAD 83 coordinates to latitude and longitude with rgdal package?

蓝咒 提交于 2019-12-21 11:29:15
问题 I have coordinates, all of which should be located in DC, but I cannot figure out how to convert them from NAD 83 to latitude and longitude in R. I'm using the spTransform() function in the rgdal package and get an error about non-conformant data. library(rgdal) nad83_coords <- data.frame(x=c(396842.6, 397886.9, 398315.5, 398154.3, 398010.3), y=c(140887.1, 139847.0, 138743.9, 139534.5, 138697.3)) coordinates(nad83_coords) <- c('x', 'y') proj4string(nad83_coords) <- CRS("+init=epsg:4269")

rgdal / readOGR - unable to read shapefile from .zip

吃可爱长大的小学妹 提交于 2019-12-21 04:15:12
问题 I'm trying to load a zip level shapefile to do some plotting, per: https://github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles http://www.nceas.ucsb.edu/scicomp/usecases/ReadWriteESRIShapeFiles etc My code: library(rgdal) library(RColorBrewer) library(ggplot2) zipmap = readOGR(dsn="file.zip/", layer="myZIPmap") I'm getting this error: Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding = input_field_name_encoding) : Cannot open file I checked the drivers but to be

Use Rcartogram on a SpatialPolygonsDataFrame object

浪子不回头ぞ 提交于 2019-12-21 00:31:52
问题 I'm trying to do the same thing asked in this question, Cartogram + choropleth map in R, but starting from a SpatialPolygonsDataFrame and hoping to end up with the same type of object. I could save the object as a shapefile, use scapetoad, reopen it and convert back, but I'd rather have it all within R so that the procedure is fully reproducible, and so that I can code dozens of variations automatically. I've forked the Rcartogram code on github and added my efforts so far here. Essentially

R: Crop GeoTiff Raster using packages “rgdal” and “raster”

二次信任 提交于 2019-12-20 14:45:18
问题 I'd like to crop GeoTiff Raster Files using the two mentioned packages, "rgdal" and "raster". Everything works fine, except that the quality of the resulting output tif is very poor and in greyscale rather than colour. The original data are high quality raster maps from the swiss federal office of Topography, example files can be downloaded here. This is my code: ## install.packages("rgdal") ## install.packages("raster") library("rgdal") library("raster") tobecroped <- raster("C:/files/krel

readOGR() cannot open file

给你一囗甜甜゛ 提交于 2019-12-17 17:44:27
问题 wmap <- readOGR(dsn="~/R/funwithR/data/ne_110m_land", layer="ne_110m_land") This code is not loading the shape file and error is generated as Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : Cannot open file I am sure that the directory is correct one. At the end / is also not there and layer name is also correct. Inside the ne_110m_land directory files I have are: ne_110m_land.dbf ne_110m_land.prj ne_110m_land.shp ne_110m_land.shx ne_110m_land.VERSION

SpatialPolygons - Creating a set of polygons in R from coordinates

ε祈祈猫儿з 提交于 2019-12-17 10:46:25
问题 I am trying to take create a set of polygons from vertex locations, saved in X,Y format. Here is an example of my data - each row represents the vertices for one polygon. the polygons are squares square <- rbind(c(255842.4, 4111578, 255862.4, 4111578, 255862.4, 4111558, 255842.4, 4111558, 255842.4, 4111578, 255842.4, 4111578), c(257397.0, 4111309, 257417.0, 4111309, 257417.0, 4111289, 257397.0, 4111289, 257397.0, 4111309, 257397.0, 4111309)) ID <- c("SJER1", "SJER2")' I am using

Aggregating seasonal means with the raster package in r

给你一囗甜甜゛ 提交于 2019-12-13 14:05:24
问题 I am attempting to aggregate daily data (35 years) to monthly then calculate seasonal mean using the raster package in R (I know how to do it with CDO). Below is my code, which outputs 4 seasonal means for all years (140 layers). How can I loop to output only 4 layers ( for the 4 seasons)?. I appreciate your help. dailydata <- brick ("dailyrain.nc") dates <- seq(as.Date("1981-01-01"), as.Date("2015-12-31"), by="day") months <- format(dates, "%Y-%m") Aggregate2Monthly <- function(x) { agg <-

Extracting values from inside polygons raster r

三世轮回 提交于 2019-12-13 04:17:28
问题 I'm trying to find the mean daily temperature for counties in South Dakota from raster grids ('bil' files) found at http://prism.oregonstate.edu/. I am getting county boundaries from the 'maps' package. library(maps) library(raster) sd_counties <- map('county','south dakota') sd_raster <- raster('file_path') How do I extract the grid cells within each county? I think I need to turn each county into it's own polygon to do this, but how? Then, I should be able to do something like the following

Rgdal package installation on Amazon Linux AMI

本小妞迷上赌 提交于 2019-12-13 02:25:34
问题 I've installed geos, proj-4.8.0 and gdal-1.9.2, yet, after installing the R package rgeos, rgdal fails to install. Here is a look at my home directory: . . . and the error I get running install.packages("rgdal", type="source") : ** building package indices ** installing vignettes ** testing if installed package can be loaded Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/mainstorage/michaeld/R/x86_64-redhat-linux-gnu-library/3.1/rgdal/libs/rgdal.so': libgdal