rgdal

Projecting my shapefile data on leaflet map using R

筅森魡賤 提交于 2019-12-31 10:37:44
问题 I (on Win7) was trying to get my shapefile data (Here are the data files.) to be displayed using leaflet package. But without any success. I only get the background map tile but not my data. I am able to see my data in QGIS though. I got the following code and description from here. library(rgdal) shapeData <- readOGR(".",'myGIS') ogrInfo(".",'myGIS') leaflet() %>% addTiles() %>% setView(lng = -106.363590, lat=31.968483,zoom=11) %>% addPolygons(data=shapeData,weight=5,col = 'red') %>%

Converting latitude and longitude points to UTM

做~自己de王妃 提交于 2019-12-27 17:34:09
问题 I found a fairly simple example of how to do this but I cant get it to work for me. I'm pretty new to R library(rgdal) xy <- cbind(c(118, 119), c(10, 50)) project(xy, "+proj=utm +zone=51 ellps=WGS84") [,1] [,2] [1,] -48636.65 1109577 [2,] 213372.05 5546301 But this is with example numbers. I have thousands of coordinates I have to transform and I cant figure out how to get them from my table to into this script My data set has 3 columns, ID, X, and Y. How can I transform them using this

Converting latitude and longitude points to UTM

浪尽此生 提交于 2019-12-27 17:33:12
问题 I found a fairly simple example of how to do this but I cant get it to work for me. I'm pretty new to R library(rgdal) xy <- cbind(c(118, 119), c(10, 50)) project(xy, "+proj=utm +zone=51 ellps=WGS84") [,1] [,2] [1,] -48636.65 1109577 [2,] 213372.05 5546301 But this is with example numbers. I have thousands of coordinates I have to transform and I cant figure out how to get them from my table to into this script My data set has 3 columns, ID, X, and Y. How can I transform them using this

Can't change raster's extent

流过昼夜 提交于 2019-12-25 14:48:39
问题 I want to crop an elevation raster to add it to a raster stack. It's easy, I did this before smoothly, adding a ecoregions raster to the same stack. But with the elevation one, just doesn't work. Now, there are several questions here in overflow adressing this issue and I tryed a lot of things... First of all, we need this: library(rgdal) library(raster) My stack is predictors2: #Downloading the stack predictors2_full<-getData('worldclim', var='bio', res=10) #Cropping it, I don' need the

cannot install rgdal package in local server, An irrecoverable exception occurred. R is aborting now…[ERROR: loading failed]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 00:37:05
问题 I'm trying to install Rgdal package, all packages and their dependancies I've installed them manuelly since my server is offline, I have struggled with those dependancies for a long time. but now I think I fix the problem, but my problem now I think has came from R, I cannot even figure out what's happen. this is the out put I gut when I run the commande install.packages("rgdal_1.2-15.tar.gz","/usr/lib64/R/library/",repos=NULL,configure.args="--with-proj-include=/usr/proj49/include/") on R: *

Plotting spatial data when two spatial objects have different CRS

别来无恙 提交于 2019-12-24 12:05:33
问题 I have a spatial polygon object and a spatial points object. The latter was created from xy latlong data vectors (called latitude and longitude, respectively) in a dataframe, while the former was simply read into R directly using rgdal. My code is as follows: boros <- readOGR(dsn = ".", "nybb") rats <- read.csv("nycrats_missing_latlong_removed_4.2.14.csv", header = TRUE) coordinates(rats) <- ~longitude + latitude At this point neither spatial object is projected. If I project these objects as

How to calculate geographic distance between two points along a line in R?

女生的网名这么多〃 提交于 2019-12-24 07:26:12
问题 Inputs I have two shapefiles that I Import into R, so that I end up with. A spatiallinesdataframe containing bus routes. A spatialpointsdataframe containing bus stops. Plotting a given route with its stops looks like this. Sample Data This link includes two shapefiles to download as a zip with a sample two routes. Target My aim is to calculate the geographic distance in meters between every pair of stops: Stop 1 to Stop 2, Stop 2 to Stop 3, etc. across the length of the underlying bus route.

rgdal - read a table within a ESRI geodatabase (gdb)

僤鯓⒐⒋嵵緔 提交于 2019-12-23 03:56:28
问题 I am trying to read a table from a ESRI geodatabase (.gdb) that has no geometry using R. readOGR is throwing an error because there is no geometry defined, which kind of make sense: library(rgdal) readOGR("gSSURGO_CO.gdb","mutext") #Error in readOGR("gSSURGO_CO.gdb", "mutext") : no features found #In addition: Warning message: #In ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : #ogrInfo: all features NULL My current solution is to access directly GDAL and dump

Converting NAD83 state plane coordinates to WS84 standard lon/lat in degrees

人盡茶涼 提交于 2019-12-22 22:46:13
问题 I tried to use this instruction to convert a set of x-y coordinates in NAD83 State Plane Coordinates to regular Lan/Lat coordinates in degrees. I could reproduce for the example given in this post but it fails to give right answer to my set! Following is what I have tried and what I obtained [wrong answer]. library(rgdal) nad83_coords <- data.frame(x=c(577430), y=c(2323270)) # My coordinates in NAD83 coordinates(nad83_coords) <- c('x', 'y') proj4string(nad83_coords)=CRS("+init=esri:102272") #

R: Error thrown while using RGDAL and RASTER packages

天涯浪子 提交于 2019-12-22 09:56:28
问题 To whom this may concern: Here is the source code: GRA_D1<- raster(files[[1]]) //Sets up an empty output raster: GRA_D1<- writeStart(GRA_D1,filename='GRA_D1.tif', format='GTiff', overwrite=TRUE) //Write to the raster, for loop: for(i in 1:dim(GRA_D1)[1]){ //Extract raster values at rows d.Frame<- matrix(NA,ncol=2,nrow=dim(GRA_D1)[2]) d.Frame[,1]<- getValues(r1[[1]],i) d.Frame[,2]<- getValues(r1[[2]],i) w.Frame<- as.data.frame(d.Frame) names(w.Frame)<- c("D1_pred_disAg","D1_pred_RK") //Apply