Tag Info

New answers tagged

1

So you have two Boolean rasters containing the same classes, urban and rural, and you would like to know the combined classes, retaining information for both the class (rural and urban) as well as the source raster (1 or 2). I would suggest using base-2 (binary) numbers for your initial class values. Reclassify your initial rasters such that: Raster1 ...


0

It looks like the first image is using the WSG84 geodetic reference system, whereas the second image is using GRS80, which is why is looks curved. This suggests the objects haven't been converted to the same CRS. Can you provide the climate data, or a sample, so I or another user can look into this further?


3

Here is a very simple and quick solution to generate a conic hill in R, using the dnormfunction: library(raster) a <- matrix(rep(dnorm(1:100, 50, sd = 25)), nrow = 100, ncol = 100, byrow = TRUE) hill <- raster(a * dnorm(1:100, 50, sd = 25)) plot(hill) You could also add some variations / heterogeneity with: hill2 <- hill + ...


0

Try: adj <- gTouches(Districts, byid = TRUE) This produced a matrix indicating which regions share a border with other regions. Does that help?


0

I think that I have figured out a way to do it. r <-raster(nrow=2,ncol=2) r[] <- round(runif(ncell(r))* 10,0) s <-raster(nrow=2,ncol=2) s[] <- round(runif(ncell(r))* 10,0) u <-raster(nrow=2,ncol=2) u[] <- round(runif(ncell(r))* 10,0) u = brick(u,r,s) u@data@attributes[1][[1]] <- values(u) At least in the toy example this does what I ...


2

If you would like to keep the object type(s) as raster I would take a look at the ratify function although, I do not think that it is intended for numeric data. require(raster) r2 <- raster(nrow=10, ncol=10) r2[] = 1 r2[51:100] = 2 r2[3:6, 1:5] = 3 r2 <- ratify(r2) rat <- levels(r2)[[1]] rat$MyRATValue <- c(100,200,300) ...


1

I extended Mark Janikas' work on interfacing R and ArcGIS. Specifically, I built an "R script to ArcGIS Toolbox converter." The user writes an annotated R script and loads it to an ArcMap add-in, which generates a ToolBox for the R script. The ToolBox can be used to load results to ArcMap. This is the work flow: And this is how the ArcMap add-in looks ...


2

There are a number of assumptions in your question which need to be addressed before you get to the implementation question. The example you provide is a biodiversity analysis that is based on a sample of varieties of a given plant species. I looked at the manual for the software that was used to generate this raster, and there is no indication that this is ...


4

Here's one method for accomplishing this in R: # Building a fake hillslope # This hillslope is 6 rows by 5 columns # alter bins / width to alter rows / columns x <- seq(-15, 15, by=0.01) z <- 1/(1+1.5^-x) # equation used to generate the shape of the hillslope plot(z) z <- 150 - (1-z)*5 plot(z) # ...


10

A good approximation to a 'textbook' hillslope with a convex upper slope, a straight mid-slope, and a concave lower slope would be a sigmoid. The most common sigmoidal function for this type of application would be the logistic function. A standard form of this function would be: z = 1 / (1 + e-x) And here is what it looks like when you model the ...


1

As you try to cluster your points by latitude you can explicitly divide them (to subsets or just add an attribute) depending on the value of the latitude. Assuming coprdinates are in Lat and Lon columns stations['clustres'] <- NA stations$clusters [stations$Lat > n] <- 'North' stations$clusters [n > stations$Lat >= n1] <- 'Center' ...


1

Your 'ENGL_NAME' shouldn't be abbreviated at all (less than 10 characters), but writeOGR has its own will, it seems. Instead of writeOGR(shp, "PolygonsV2", speciesname, driver="ESRI Shapefile") you might try currdir <- getwd() #store your current working directory setwd(paste(currdir,"PolygonsV2",sep="/")) #switch to your desired folder ...


5

I'd really give SpatiaLite a go for getting this done! Most conveniently you could use the QSpatiaLite plugin in QGIS. Just set up a polygon grid with a sensible size for gridcells. Then intersect the grid with the ethnic group's polygon and calculate area of each intersection. With the resulting table you can calculate your indices by using the ...


3

In QGIS, you could generate a point grid on top of your polygons. You'll find this function under Vector -> Research tools (I think it's called that in English, my QGIS version is in another language.) You'll have to find some reasonable granularity when it comes to the point grid spacing. Then under the Vector menu, you do a Join attributes by location ...


4

Use spTransform to transform the coordinates to WGS84: library("rgdal") library("rgeos") map <- readOGR(".", "kommuner1983") map_wgs84 <- spTransform(map, CRS("+proj=longlat +datum=WGS84")) plot(map_wgs84, axes=TRUE) gCentroid(map_wgs84) # SpatialPoints: # x y # 1 10.05 55.96 # Coordinate Reference System (CRS) arguments: +proj=longlat ...


1

Looking at the examples provided with the ?iconlabels function, the author uses the column landuse from the meuse dataset. That column is from class factor. So I tried to convert your column cluster from class integer to class factor and it worked. X = read.table(text="code,cluster,name,longt,latit 101,1,A,-89.6171,35.24992 ...


0

I think you can't... You first have to label each classes to compare them. Kmean classify unsupervisedly so without any prior information and so cannot define any kind of classes. If you have a reference layer, you can make a labelling by a majority voting. Here's a quite more efficient code for majority voting than using the 'raster' package function zonal ...


1

Nine points is a quite small number, so I would use some arbitrary boundary instead of trying to build a complex algorithm that might "go wild". I suggest that you use r.grow.distance in grass to create a distance layer around your points, and to set a threshold that would constraint the size of your study area (for instance, the largest distance value ...


1

First, you should add some fields : 1) sogtest (select by attribute SOG!=0, and use field calculator to fill the selected values with 1) 2) X, Y and Z (use the field calculator to compute your "cartesian" coordinates) Then you can use "dissolve"(or summarize table if you don"t need to merge the geometries) with sogtest as a case field and the required ...


1

Below is a work around method using python and bunch of libraries such as netCDF4, numpy and shapefile. With Anaconda, these library installations are very much easy. The steps of the method are Import WRF ARW output into python, by python netCDF4 library. Query WRF ARW output variable XLAT, XLONG into numpy array of latitude and longitude using python ...


1

I believe that you need to set the argument "longlat=TRUE". Since your data is in geographic coordinates it is likely that the kernel is being incorrectly defined. You also may want to explicitly specify the data slot "data = spdf@data". Please use caution with specification of the GWR method in anything other than exploratory analysis of nonstationarity. ...


2

You said: I am trying to extract values of raster cells on points using extract from raster package in R (similar to 'Extract Values to Points' in ArcGIS-10.2). Lets set up a test raster: require(raster) r = raster(ncol=100,nrow=100,xmn=0,xmx=1,ymn=0,ymx=1) r[]=runif(100*100) You said: After doing so in order to check integrity, I computed ...


-1

You might want to give a try to the GMT tool grdtrack. You can start by reconverting to your raster to a NetCDF file using gdal_translate: gdal_translate -of NetCDF myraster.tif myraster.grd and then put your x,y locations in a text file: x1, y1 x2, y2 .., .. then call grdtrack on that NetCDF grid based on your table of locations: grdtrack ...


0

I found an answer. I basically take everything I need into the colorkey function as follows. plot3 <- spplot(mymap, "percentage", col.regions = plotclr, at = round(class$brks, digits=1), colorkey = list(labels = list( labels = c("0%", "1%","2%","3%","4%","5%","6%","7%"), width = 2, cex = 2))) Width changes ...



Top 50 recent answers are included