Tag Info

Hot answers tagged

6

If you know R, you can use the package "gdalUtils" and run gdal_translate to do that. If you are on Linux make sure to install GDAL. If you are on Windows, you're good to go. These are the basic commands to handle the conversion to .tiff and the reprojection to WGS84. out.files <- list.files(getwd(), pattern="hdf$", full.names=FALSE) #create a list with ...


4

The extract function is behaving exactly as it should. You can force the crop function to use the extent of the polygon and then mask the object to return the exact raster representing the polygon area. If you continue to receive the error it means that your data, in fact, does not overlap. Please keep in mind that R does not perform "on the fly" ...


3

It may be prudent to back up a step and explore the "spdep" package in more detail and not just try to recreate an analysis that you do not entirely understand. Bivand's code is irrelevant if we can not see the structure and intent of your analysis. A .gal file is a weights matrix produced by the software GeoDa. The code provide is intended to demonstrate ...


2

It seems that you are over complicating this problem. Just because data is spatial does not mean that you are compelled to apply a spatial statistical model. If you distill down your question, all you are after is a statistical relationship between rate of illness (rate_ill) and distance to water (disw). This can be tested using a simple bivariate linear ...


2

You can use functions from the rgeos package to extract such regions (e.g. gIntersection, gDifference). I use gDifference in this example, because gIntersection returns a SpatialCollections object here: # define rectangular region y_lim <- c(-1, 1)*23.5 rect_lim <- cbind(c(rep(bbox(ao)["x", ], each=2), bbox(ao)["x", 1]), c(y_lim, ...


2

If you draw the axes (argument axes=TRUE in your plot statements), you can see the different coordinate systems: library("rgdal") boros <- readOGR(dsn=".", "nybb") rats <- read.csv("nycrats_missing_latlong_removed_4.2.14.csv", header=TRUE) coordinates(rats) <- ~longitude + latitude op <- par(mfrow=c(1,2)) plot(rats, axes=TRUE) plot(boros, ...


2

I used gintersection, as Jeffrey Evans suggested, and then I think I was able to assign the attribute from each original grid to the new grid with the following code: both.polys <- gIntersection(poly.df1, poly.df2, byid=TRUE) both.polys #class : SpatialPolygons #features : 16 #extent : 2.8, 5.5, 2.8, 5.5 (xmin, xmax, ymin, ymax) #coord. ...


1

If you have to do this once, I would also recommend using gdal_translate like in the above answer given by Filipe Dias. However, if you are working a lot with MODIS data, you should probably also have a look at Matteo Mattiuzzi's MODIS package (see modis: R Development Page). It is easy to use and offers a lot of opportunities to download and process ...


1

The shapefile format has some limitations due to the underlying dbase database format. See: http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Geoprocessing%20considerations%20for%20shapefile%20output In your case, the limit of 10 characters field name and 255 fields total is hit. Try some other format, like spatialite. Or think about ...


1

Are your grass binaries really in "C:/Program Files/R/R-3.1.0/bin/i386"? The "gisBase" argument is the path to your GRASS install. Something like this: loc <- initGRASS("C:/Program Files (x86)/GRASS 6.4.2", home=getwd(), gisDbase="GRASS_TEMP", override=TRUE ) Here is an example R/GRASS session that calculates the 3x3 surface relief ...


1

You can use "writeGDAL" in the rgdal package. Use the "asc" extension to specify an ESRI ASCII raster format. require(rgdal) # Pull sp SpatialPixelsDataFrame kriging.pred <- kriging_result$krige_output # Write Kriging estimate and variance writeGDAL(kriging.pred["var1.pred"], "KrigingPred.asc") ...


1

Other than "first one encountered" I am not sure what criteria one would use to select a point to retain. It seems quite arbitrary and a point may share multiple neighbors with your distance criteria but would not be retained if not in the correct selection order. This could add serious bias to your mean. It seems that you should calculate your neighbor ...


1

It would be good if you provided a bit more detail to your question and indicated what you have already tried. Working examples are always appreciated. Here is a function that calculates a correlogram on point data. You could, in theory, modify it to operate on a raster or on a subsample of a raster. Although, I wonder about the computational tractability ...


1

Well! Solution was simple. Just take the circle shp., convert it into a raster (yellow circle) with equal resolution as master raster of forest cover. Than fuse this two rasters into one with raster calculator. Now I am able to distinguish between non-forest area within circle and empty areas in four corners. If someone will have a similar problem (of ...


1

I always appreciate the application of "ggplot" but this can easily be done using the low level plotting functions available in R. I like @mdsumner's solution because it is so efficient. However, you do not have clear control of a specific color pallet. A simple approach is to use "ifelse" to create a vector of equal length to your variable, containing the ...


1

Here is one suggestion: require(ggplot2) #function fortify, function ggplot require(plyr) # function join spLinesDF@data$id = rownames(spLinesDF@data) #join id column to data slot on SpatialLinesDataFrame df = fortify(spLinesDF,region="id") #create data frame from SpatialLinesDataFrame df = join(df, spLinesDF@data, by="id") #add Turbity information ...


1

255 is the default NoData value in QGIS. I am not sure, what exactly the problem is with the way you tried it, but you could use the GDAL Python bindings to do what you want. For instance the following script converts your shp to a polygon based on the attribute NAME_2_NUM. Import the libraries import ogr, gdal, osr Open your shapefile source_ds = ...


1

You may want to enjoy the new temporal GIS framework in GRASS GIS 7: GRASS as Temporal GIS presentation PDF A temporal GIS for field based environmental modeling (article) Manual pages: http://grass.osgeo.org/grass70/manuals/temporalintro.html An initial release of GRASS GIS 7 has been done two days ago at the Vienna OSGeo Code sprint: ...


1

Answering to myself. Using R and package "rts" it is possible to create a time series: library(raster) library(ncdf) library(stringr) library(rts) stack<-stack("pp_0.25deg_reg_v9.0.nc") #Create raster stack datas<-c() for (i in 1:length(stack@layers)) { word<-str_sub(as.character(stack@layers[[i]]@data@names), start=2, end=11L) ...


1

.GAL files were created as a means of specifying neighbor/contiguity relationships within the GeoDa software package. They're text files containing lots of 0s and 1s, basically. You can read more details here and in the GeoDa documentation. It looks to me like the point of that Bivand article is to specify contiguity relationships in R without needing such ...


1

I think the most easy way to accomplish this is to use loops, and create the lag.listw() for your count variable for each year. Something like this? spatlag <- data.frame(id=NULL, time=NULL, lag=NULL) for (y in sort(unique(data$time))){ print(y) Then inside the for loop you subset both the points and polygons, and execute the overlay. Then you ...


1

I think you can save the attributes table of your shapefile as a .csv table (Save as -> Choose Format .csv) and then make a Qgis-R script that accepts a table as input: ##Folder= folder ##Table=table setwd(Folder) Table*2->table_out write.table(table_out,"table_out.csv",row.names=F) Note that Qgis-R can not create "table" output ...


1

In my experience this problem is nearly always caused by: High precision in your coordinates (43.231499999999996), combined with Lines that are almost coincident but not identical The "nudge" approach of the ST_Buffer solutions lets you get away with #2, but anything you can do to resolve these underlying causes, like snapping your geometry to a 1e-6 ...


1

I ran into this same problem (Postgres 9.1.4, PostGIS 2.1.1), and the only thing that worked for me was to wrap the geometry with a very small buffer. SELECT ST_Intersection( (SELECT geom FROM table1), ST_Union(ST_Buffer(geom, 0.0000001)) ) FROM table2 ST_MakeValid didn't work for me, nor did the combination of ST_Node and ST_Dump. The buffer didn't ...


1

Just to close this loose end, since I asked the question a new package was released called osmar which contains a vignette of how to implement shortest path algorithms in R using Open Street Map data: http://osmar.r-forge.r-project.org/ . It uses the function get.shortest.paths from the igraph package. Excellent article on this can be found here: ...



Only top voted, non community-wiki answers of a minimum length are eligible