rgdal

Spatial line start and end point in R

拈花ヽ惹草 提交于 2020-06-01 06:41:10
问题 I am attempting to use the sp package to access the start and end points of a linestring, similar to what ST_StartPoint and ST_EndPoint would produce using psql . No matter how I try to access the line, I get errors or NULL value: > onetrip@lines[[1]][1] Error in onetrip@lines[[1]][1] : object of type 'S4' is not subsettable > onetrip@lines@Lines@coords Error: trying to get slot "Lines" from an object of a basic class ("list") with no slots > onetrip@lines$Lines NULL The only solution that

Spatial line start and end point in R

╄→尐↘猪︶ㄣ 提交于 2020-06-01 06:41:10
问题 I am attempting to use the sp package to access the start and end points of a linestring, similar to what ST_StartPoint and ST_EndPoint would produce using psql . No matter how I try to access the line, I get errors or NULL value: > onetrip@lines[[1]][1] Error in onetrip@lines[[1]][1] : object of type 'S4' is not subsettable > onetrip@lines@Lines@coords Error: trying to get slot "Lines" from an object of a basic class ("list") with no slots > onetrip@lines$Lines NULL The only solution that

Obtaining Latitude and Longitude with from Spatial objects in R

我的未来我决定 提交于 2020-03-20 12:48:20
问题 I want to obtain the latitude and longitude from a shapefile. Until now, I only know how to read the shapefile. library(rgdal) centroids.mp <- readOGR(".","35DSE250GC_SIR") But how I can extract the latitude and longitude from centroids.mp? 回答1: There's a few levels to this question. You ask for longitude and latitude, but that may not be the coordinate system used by this object. You can get the coordinates like this coordinates(centroids.mp) Note that the "centroids" will be all of the

Obtaining Latitude and Longitude with from Spatial objects in R

大城市里の小女人 提交于 2020-03-20 12:47:05
问题 I want to obtain the latitude and longitude from a shapefile. Until now, I only know how to read the shapefile. library(rgdal) centroids.mp <- readOGR(".","35DSE250GC_SIR") But how I can extract the latitude and longitude from centroids.mp? 回答1: There's a few levels to this question. You ask for longitude and latitude, but that may not be the coordinate system used by this object. You can get the coordinates like this coordinates(centroids.mp) Note that the "centroids" will be all of the

How to load all fields/ExtendedData (not just 'name' and 'description') from KML layer into R

浪子不回头ぞ 提交于 2020-02-28 23:45:53
问题 I've been working on loading KML files into R to make web maps with Leaflet/Shiny. The import is pretty simple (using this sample KML): library(rgdal) sampleKml <- readOGR("D:/KML_Samples.kml", layer = ogrListLayers("D:/KML_Samples.kml")[1]) In this example, ogrListLayers pulls in all of the kml layers, and I subset only the first element/layer. Easy peasy. The problem is that using this method to read KML layers only pulls in two fields: "Name" and "Description," as seen below: > sampleKml <

How to extract specific values from a DEM (digital elevation model)?

半城伤御伤魂 提交于 2020-01-04 06:25:26
问题 I'm trying to calculate elevation data for hiking routes, using open data (avoiding licensing constraints like Google). I was able to read a public DEM of my country (with a 10-metres resolution) using readGDAL (from package RGDAL), and proj4string(mygrid) gives me: "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0" The beginning of the .asc file is: ncols 9000 nrows 8884 xllcorner 323256,181155 yllcorner 4879269,74709 cellsize 10 NODATA_value -9999 978 998 1005

How to extract specific values from a DEM (digital elevation model)?

左心房为你撑大大i 提交于 2020-01-04 06:25:22
问题 I'm trying to calculate elevation data for hiking routes, using open data (avoiding licensing constraints like Google). I was able to read a public DEM of my country (with a 10-metres resolution) using readGDAL (from package RGDAL), and proj4string(mygrid) gives me: "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0" The beginning of the .asc file is: ncols 9000 nrows 8884 xllcorner 323256,181155 yllcorner 4879269,74709 cellsize 10 NODATA_value -9999 978 998 1005

How do I import an openstreetmaps shape file in R and extract lat/long centroids?

不问归期 提交于 2020-01-04 05:39:29
问题 I am trying to import an openstreetmaps shape file in R using the rgdal package. The shape file I downloaded has 5 components in it: places.cpg places.dbf places.prj places.shp places.shx The files can be accessed at the following location: https://drive.google.com/open?id=0B1ITb_7lHh1EUFVfVWc4ekRfSnc I have to do the following: 1) Import the shape file 2) Extract lat/long of the point or centroid of shape in case of polygon 3) Attach the lat/long pair to the dbf file to do some analysis I am

RGDAL won't install

别说谁变了你拦得住时间么 提交于 2020-01-02 01:43:08
问题 I can't get RGDAL to install in R. I'm using Ubuntu 12.04. configure: error: gdal-config not found or not executable. ERROR: configuration failed for package ‘rgdal’ * removing ‘/home/james/R/x86_64-pc-linux-gnu-library/3.2/rgdal’ Warning in install.packages : installation of package ‘rgdal’ had non-zero exit status I found some solutions which said to do this: sudo apt-get install aptitude sudo aptitude install libgdal-dev sudo aptitude install libproj-dev I follow these through, accepting

Projecting my shapefile data on leaflet map using R

拜拜、爱过 提交于 2019-12-31 10:38:13
问题 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') %>%