raster

Pixel values of raster records to be inserted in the table as columns

不想你离开。 提交于 2019-12-11 10:49:01
问题 I have a table with following columns: (ID, row_num, col_num, pix_centroid, pix_val1). I have more than 1000 records. I am inserting my data using: insert into pixelbased (row_num, col_num, pix_centroid, pix_val) select (ST_PixelAsPolygons(rast, 1)).x as X, (ST_PixelAsPolygons(rast, 1)).y as Y, (ST_Centroid((ST_PixelAsPolygons(rast, 1)).geom)) as geom, (ST_PixelAsPolygons(rast, 1)).val as pix_val1 from mytable where rid=1` Now I am trying to insert all the other records as a column and _pix

RasterLayer 16-bits into a RasterLayer 8-bits

廉价感情. 提交于 2019-12-11 10:02:05
问题 I have a tried to convert a RasterLayer 16-bit into a RasterLayer 8-bit in R, but I did not have success. Any ideas ? Thanks! 回答1: If you want to convert your RasterLayer from 16-bit to 8-bit you need to stretch your values into the 8-bit interval (0-255 unsigned) first. Then you can save it as an 8bit image: #sample raster library(raster) ras16b <- raster(x=matrix(as.integer(rnorm(180*180,1000,50)),180,180)) #convert to 0-255 using the calc. function and basic raster algebra ras8b <- calc

error in mask a raster by a spatialpolygon

混江龙づ霸主 提交于 2019-12-11 09:57:01
问题 I have raster of the following features: library(raster) library(rgeos) test <- raster(nrow=225, ncols=478, xmn=-15.8, xmx=32, ymn=-9.4, ymx=13.1) I want to mask in this raster the cells that are within a given distance of a point. I create the spatial points as followed: p2=readWKT("POINT(31.55 -1.05)") Then I create a spatial polygon object by adding a 0.5 buffer: p2_Buffered <- gBuffer(p2, width = 0.5) mask(test, mask=p2_Buffered,inverse=T) When I mask my raster given this spatial object,

R: Error in rasterize when used on polygons

孤人 提交于 2019-12-11 09:47:14
问题 Does anyone know why rasterize would return the following error when used on polygons: Error in rv[[ii]] : subscript out of bounds Using other common R functions, such as mean , also give the same error, but rasterize options, such as 'last' , work fine. I haven't encountered this problem in the past on previous versions of raster (currently using raster_2.3-0). I've attached code I grabbed from an example in ?rasterize : library(raster) p1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,

dimensions of kde object from ks package, R

一世执手 提交于 2019-12-11 08:31:10
问题 I am using the ks package from R to estimate 2d space utilization using distance and depth information. What I would like to do is to use the 95% contour output to get the maximum vertical and horizontal distance. So essentially, I want to be able to get the dimensions or measurements of the resulting 95% contour. Here is a piece of code with as an example, require(ks) dist<-c(1650,1300,3713,3718) depth<-c(22,19.5,20.5,8.60) dd<-data.frame(cbind(dist,depth)) ## auto bandwidth selection H.pi2<

Calculate selected area from stacked raster object

徘徊边缘 提交于 2019-12-11 06:48:16
问题 As I have only recently started using R for spatial analysis, and I am not a geographer or spatial data specialist by any means, I have a -what I presume to be- relatively simple question. I am trying to calculate the area of part of a stacked raster object that meets certain conditions. More specifically, from a dataset from the deep sea in the south Atlantic, I have stacked two raster objects (depth and slope) that are further identical in coordinate system (WGS84) and x-y (Lat-Long)

Importing raster data into NetLogo results in a row/column of NaN values

一个人想着一个人 提交于 2019-12-11 06:20:31
问题 When importing rasters into NetLogo, there is an additional row or column of NaN cells that are added along one of the borders of the NetLogo world, which does not exist in the raster. Is this the same issue that was raised here: https://github.com/NetLogo/GIS-Extension/issues/5 ? In my case though, they are not random cells that have a value of NaN but cells along a border. EDIT: Here's the code I used to import the raster layer: set rasterLayer gis:load-dataset "x.asc" resize-world 0 gis

Plot georeferenced raster images in Plotly (R API)

冷暖自知 提交于 2019-12-11 06:13:14
问题 I would like to use Plotly in R to create 3D modells of trenches of archaeological excavations. I'm quite successful to plot point and surface data (Example: Vignette of the R package I'm working on), but I would also like to add raster information of the georeferenced profile pictures of the trenches. I didn't find any way to plot raster data in Plotlys 3D environment. The only solution I came up with so far (thanks to this post) was to create a 3D modell of the profile with SFM using

Unable to create a scalable png image using C# in .NET

纵然是瞬间 提交于 2019-12-11 06:04:42
问题 I am trying to create an image based on a string. The image needs to be raster (otherwise it will lose resolution if I need to zoom out). I am using the following code: Bitmap bitmapimage = new Bitmap(200, 100); Graphics bitmapGraphics = Graphics.FromImage(bitmapimage ); bitmapGraphics .DrawString("test", new Font("Arial",50), Brushes.Black, new Point(0, 0)); bitmapimage .Save("Image.png", System.Drawing.Imaging.ImageFormat.png); textPictureBox.Image = bitmapimage ; What I get is an image

How to put conditions using the decimals in calculations?

孤街醉人 提交于 2019-12-11 05:54:49
问题 Having two rasters (values are floats with 5 decimals) with the same dimensions. The code given below makes one file out of two rasters r and r1. If r is bigger,put blue ,otherwise put red. This code worked well but I was asked to add another condition. How this code works: If r is 0.229 and r1 is 0.228 then r is bigger(notice third decimal). what I need is to specify the first two decimals for example: r= 0.228 r1=0.224 put yellow colour(they are rather similar) r= 0.238 r1=0.224 put blue