rgdal

Value of coordinates() for a SpatialPolygonsDataFrame object?

淺唱寂寞╮ 提交于 2019-12-04 04:57:28
问题 I am trying to get a pseudo barycenter for polygons in a spatial polygon dataframe. Today I stumbled upon the coordinates function that actually returns something for a SpatialPolygonsDataFrame . Unfortunately I found nothing in the help of coordinates about the value for SpatialPolygonsDataFrame . Could somebody tell me what these coordinates are? 回答1: It is the polygon centroid. The source code is found here, look for function FindCG . The equations computed are equivalent to those found on

Read shape file with readOGR verses readShapePoly

流过昼夜 提交于 2019-12-04 00:27:30
I have read a shapefile using readShapePoly in the maptools package, but cannot read that same file with readOGR . I am hoping someone may be able to help me read the shapefile with readOGR . I downloaded the file orcounty.shp from here: http://geography.uoregon.edu/geogr/topics/maps.htm I also downloaded the associated files: orcounty.shx , orcounty.sbx , orcounty.sbn , and orcounty.dbf and put all five files in the folder: c:/users/mark w miller/gis_in_R/shapefile_example/ The following code reads the shapefile and displays some attributes: library(maptools) setwd('c:/users/mark w miller/gis

Plotting a raster behind a shapefile

雨燕双飞 提交于 2019-12-03 13:19:14
问题 How can I plot a "raster" object behind a shapefile object? Both plot fine on their own but the points don't plot over the raster: require(rgdal) require(maptools) require(raster) myproj = "+proj=utm +zone=12 +north +ellps=WGS84 +units=m" shp = readShapeSpatial(fn.shp, proj4string = CRS(myproj)) ras = raster(fn.tif) plot(ras) plot(shp, bg="transparent", add=TRUE) 回答1: Overplotting raster plots with points, lines, and polygons should work just fine, as the following example shows. My best

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

半腔热情 提交于 2019-12-03 03:50:17
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_1129_2012_254dpi_LZW.tif") ex <- raster(xmn=648000, xmx=649000, ymn=224000, ymx=225000) projection(ex)

Projecting my shapefile data on leaflet map using R

别等时光非礼了梦想. 提交于 2019-12-02 19:49:23
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') %>% addMarkers(lng = -106.363590,lat=31.968483,popup="Hi there") This is what I see in my internet browser. I do

R: how to write a raster to disk without auxiliary file?

家住魔仙堡 提交于 2019-12-01 20:26:17
问题 I'm writing a dataset to file in ERMapper format (.ers) using the Raster package in R, but I'm having issues with the resulting .aux.xml auxiliary file (which I'm actually not interested in). Simple example: rst <- raster(ncols=15000,nrows=10000) rst[] <- 1.234 writeRaster(rst, filename='_test.ers', overwrite=TRUE) The writeRaster() line takes some time to execute, the data file is quite large, about 1.2GB on disk. When checking what's happening while writeRaster() is executed, I find that

R: how to write a raster to disk without auxiliary file?

佐手、 提交于 2019-12-01 20:14:19
I'm writing a dataset to file in ERMapper format (.ers) using the Raster package in R, but I'm having issues with the resulting .aux.xml auxiliary file (which I'm actually not interested in). Simple example: rst <- raster(ncols=15000,nrows=10000) rst[] <- 1.234 writeRaster(rst, filename='_test.ers', overwrite=TRUE) The writeRaster() line takes some time to execute, the data file is quite large, about 1.2GB on disk. When checking what's happening while writeRaster() is executed, I find that the .ers file (header file + associated data file) is typically generated in about 20 sec. Then, it takes

Error: isTRUE(gpclibPermitStatus()) is not TRUE when using fortify function, rgdal package

£可爱£侵袭症+ 提交于 2019-12-01 18:09:55
问题 I am trying to work with spatial data that I downloaded here in order to make a map in ggplot2. library(rgdal) library(ggplot2) library(rgeos) df <- readOGR(mydirectory, layer = 'gem_2013_v1') df.fort <- fortify(df, region = "AANT_INW") I keep on getting this error when using the function fortify: Error: isTRUE(gpclibPermitStatus()) is not TRUE Has anyone an idea about what's going wrong here? Most appreciated! EDIT: As mentioned in the comments a possible duplicate of this question can be

Convert latitude/longitude to state plane coordinates

怎甘沉沦 提交于 2019-12-01 04:51:53
I've got a dataset with latitude and longitude which I'd like to convert to the state plane coordinates for Illinois East, using EPSG 2790 ( http://spatialreference.org/ref/epsg/2790/ ) or maybe ESRI 102672 ( http://spatialreference.org/ref/esri/102672/ ). This has definitely been asked before; my code is based on the answers here ( "Non Finite Transformation Detected" in spTransform in rgdal R Package and http://r-sig-geo.2731867.n2.nabble.com/Converting-State-Plane-Coordinates-td5457204.html ). But for some reason I can't get it to work: library(rgdal) library(sp) data = data.frame(long=c(41

Rgdal installation failed on ubuntu 16.04

余生长醉 提交于 2019-11-30 09:30:22
问题 I have been trying to install rgdal from RStudio Version 1.0.44 on ubuntu 16.04 then I was getting the gdal-config not found error. I resolved this by installing the libgdal1-dev & libproj packages but now i'm getting the following error. Someone help me resolve this. Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/home/hetch/R/x86_64-pc-linux-gnu-library/3.3/rgdal/libs/rgdal.so': /usr/lib/x86_64-linux-gnu/libgeos_c.so.1: undefined symbol: