Tag Info

New answers tagged

0

Do you see "PostgreSQL" with ogrDrivers()? If not, then your version of rgdal and GDAL/OGR was not configured to support the PostgreSQL driver. If you didn't compile any of these components and used the binaries of rgdal from CRAN, you may want to kindly ask Roger, the maintainer, if it could be supported for a future release of the binary for your platform ...


2

I have committed changes in the repository that implement the axis. Use this code to install the latest development version: ## install.packages("devtools") devtools::install_github("rastervis", "oscarperpinan") Then, use the new argument axis.margin to enable the axis. f <- system.file("external/test.grd", package="raster") r <- raster(f) ...


1

Use crs function. If r is your raster: crs(r) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0" Of course, you need to be sure it is the correct projection for your raster.


0

If you're working in R then your shapefile and .csv need to be loaded as a data.frame or a data.table. You can use join() to merge them. Do you have any more information about what kind of shapefile you have? I've had luck doing the following when I merge shapefiles and data. Note that you need to leave off the .shp extension in the "layer" argument. I ...


1

You should use rgdal, specifically writeOGR (which is for vector data) to write the table to Postgis. Note that you must have a spatialdataframe as designated by the sp package (autoloaded with rgdal), I suspect your results of rasterToContour are the correct format. #R code assumes library(rgdal) writeOGR(x, "PG:dbname='BDDMeteo' user=user ...


0

You might try a system like rpostgresql which allows you to simply connect to your postgresql / postgis database rather than exporting the tables out of your database. Another link: http://cran.r-project.org/web/packages/RPostgreSQL/index.html Database interface and PostgreSQL driver for R This package provides a Database Interface (DBI) compliant ...


0

you can use OTB for this. You can build a vrt to stack all your bands, then run OTB bandmath for the per pixel calculation. Note that you can also create your own filter because OTB is open source for a specific tool, because OTB is open source. otbcli_BandMath -il image_stack.vrt -out out.tif -exp "your expression" use b1, b2 etc to name the bands ...


2

To answer your question directly, crime obviously follows population, just like disease or any other human "event" you might be measuring. To directly compare you could normalise both population and crime figures to z-scores, and classify each region as HH, LL, HL, LH, or come up with a way to combine the figures, but I think to answer your question you need ...


1

The following example shows two ways to get at the max raster value in a stack. The first utilizes max() which also gives you a host of other useful information. The second method uses maxValue(), which gives just the max value of both the rasters in the stack library(raster) # Generate some georeferenced raster data x = matrix(rnorm(400),20,20) rast ...


1

This is an example of what you can do with rasterVis and sp packages. You will have to adapt to your own use. library(rasterVis) library(sp) # Download States boundaries (might take time) out <- getData('GADM', country='United States', level=1) # Extract California state California <- out[out$NAME_1 %in% 'California',] # Plot raster and California: ...


0

I found to ways to read aster metadata in envi (hdf format). 1.- using "envi_file_query" to read a particular attribute ; set the name of the file FILE_NAME='link to .hdf' ; open data as aster image envi_open_data_file, FILE_NAME, /aster, r_fid=fid ;query the metadata inserted in the hdf (global attributes) envi_file_query, fid[0], nb=nb, ...


2

kappa does not quantifies the level of agreement between two datasets. It represents the level of agreement of two dataset corrected by chance. The reason why you have a large difference between kappa and overall accuracy is that one of the classes (class 1) accounts for the large majority of your map, and this class is well described. Overall accuracy is ...


0

I have not managed to do it in R either.. and I have also spent countless hours. What I do now is this: Use the ModisReprojectionTool to extract the layers and the subsets I need as binary files read the binary files and if necessary convert them to "raster" objects. I mainly use them as matrix and in the end transform them into raster-objects to write ...


2

Since you didn't provide a reproducible example nor an error message, see if this code snippet gets you started: library("raster") x <- getData('GADM', country='ITA', level=1) class(x) # [1] "SpatialPolygonsDataFrame" # attr(,"package") # [1] "sp" set.seed(1) # sample random points p <- spsample(x, n=300, type="random") p <- ...


0

I don't know how to do with R to join a shapefile with a csv. However, if this can help you, you can also do this on QGIS using the pluggin MMQGIS.


1

The Kappa index of agreement (KIA) will tell you how much better, or worse, your classifier is than what would be expected by random chance. If you were to randomly assign cases to classes (i.e. a kind of terribly uninformed classifier), you'd get some correct simply by chance. Therefore, you will always find that the Kappa value is lower than the overall ...


0

There is no well-documented conditional conditional function in QGIS raster calculator, however, there exists a hack: (condition) = 0 This will create a raster with values 0 where condition is not met, and 1 elsewhere. So, you can create basic if-then-else calculation like this: (("raster@1" > 4) = 0) * 4 + (("raster@1" < 4) = 0) * 5 The ...


1

Well, the official Python wrappers for NetCDF4 are here: https://github.com/Unidata/netcdf4-python


2

Edit You can try the following: for(i in seq(from=1, to=length(list.ras), by=4)){ Obj <- levelplot(subset(RAD1998.all, i:(i+3))) png(paste("1998_",outlist[[i]],".png",sep="")) print(Obj) dev.off() }


2

You can control the number of plots per graphic device using the mfrow and mfcol arguments in par(). par(mfrow=c(3,4)) for(i in 1:12) {plot(runif(100),runif(100)*0.05)}


1

Use the syntax object_ name[,-(1:5)] to remove columns 1 to 5 or object_name[,-c(1,5)] to drop columns 1 and 5. See the example below (with comments): require(maptools) #load shapefile from maptools package to make a reproducible example. xx <- readShapeSpatial(system.file("shapes/sids.shp", package="maptools")[1], IDvar="FIPSNO", ...


6

Seems to be a simple application of gDifference from the rgeos package: > require(rgeos) > ukhole = gDifference(uk, lnd) Warning message: In RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, "rgeos_difference") : spgeom1 and spgeom2 have different proj4 strings > plot(ukhole) The projection warning is because the LondonBoroughs shapefile doesn't ...


3

I've created a small function for this very purpose and it has been used by others with good reviews! gClip <- function(shp, bb){ if(class(bb) == "matrix") b_poly <- as(extent(as.vector(t(bb))), "SpatialPolygons") else b_poly <- as(extent(bb), "SpatialPolygons") gIntersection(shp, b_poly, byid = T) } This should solve your problem. Further ...


0

If you would like to do this in R, you might want to have a look at the blog post by Oscar Perpiñán Lamigueiro. Its not exactly what you are looking for, but there might be a way to modify it to work for your purposes. In my last post I described how to produce a multivariate choropleth map with R. Now I will show how to create a map from raster ...


1

Getting a p value is not that easy. Marcon and Lang (Testing randomness of spatial point patterns with the Ripley statistic, http://arxiv.org/abs/1006.1567) have demonstrated that (K1, K2..Kn) where K1, K2..Kn are the values of the Ripley s K function at different distances is a Gaussian vector. They have then computed its mean and covarianace matrix in the ...


1

The Java Topology Suite includes a TopologyPreservingSimplifier. The code does not include a reference for the implementation, beyond stating that it operates in a similar manner to Douglas-Peucker, with additional constraints on altering the topology. This functionality has made it into the Java-to-C++ translation of JTS, libgeos, which is further ...


2

The formula for global Moran's I is: where i is an index of analysis units (basically, measurement units of of your map, or in your case pixels in the raster) and j is an index of the neighbors of each map unit. The formula for local Moran's I is extremely similar, except that since local Moran's I is calculated separately for each analysis unit indexed ...


0

my.attribute <- read.csv.... IMPORT TABLE WITH ATTRIBUTE TO ADD #load some key spatial libraries for R library(maptools) library(sp) library(rgdal) library(raster) #load your shapefile ?readOGR my.shapefile <- readOGR(dsn="C:/leads/to/your/shapfiles", layer="yourlayername") plot(my.shapefile) # does it look ok? ?merge joined <- ...


3

The problem was that I had run out of space to write to disk, and the map algebra commands I was using were attempting to generate and write large temporary raster files.


1

I thought I'd answer this myself just in case anyone else with a similar problem ever stumbles on this. Using the above advice on converting my Cartesian coordinates to polar coordinates, I've made a function which calculates a minimum enclosing circle around the x,y coordinates, and divides this circle into a user-defined number of 'grid' cells with equal ...


0

See my example and answer ### Preparing the SpatialPointsDataFrame spdf <- matrix(as.numeric(NA), nlevels(Poly$MatchID), 1) spdf <- as.list(spdf) ### Sample the coordinate, match it with data in spdf. It create a list fore each factor of the MatchID ### sample(spsample()) fix the size of the sample for (i in seq(Poly$MatchID)) spdf[i] <- ...


2

After a lot of attempts I have this solution, probably not so clean. Comments, improvements or other way to answer are much welcome! ### Preparing the SpatialPointsDataFrame spdf <- matrix(as.numeric(NA), nlevels(Poly$MatchID), 1) spdf <- as.list(spdf) ### Sample the coordinate, match it with data in spdf. It creates a list fore each factor of the ...



Top 50 recent answers are included