Tag Info

Hot answers tagged

8

Since you also have a QGIS tag how about a GDAL solution? Within QGIS: Via the menubar select ---> Raster > Conversion > Rasterize (raster to vector) Then set your attribute and check the output. Rasterize whole map within QGIS: Go File -> Save as image, then choose tif. (unfortunately this does not work for map composer) Via the command line using ...


7

You could use gdal_rasterize either from the command line or QGIS to generate your raster. To make sure your points sit within a cell, you need to do two things. First, set the target resolution to 5m, and set the extents to be 2.5m bigger all around than the source data. So, assuming your dataset goes from [1000 2000] [2500 3250], giving you your 75,000 ...


6

If your data contains xyz data (where z is the raster value) and your points are on a regular grid (no need for interpolation). library("raster") r <- rasterFromXYZ(as.data.frame(travel)[, c("x", "y", "z")]) If you need interpolation, you can use akima library : library("raster") library("akima") steps <- 100 isu <- with(travel@data, interp(x, ...


6

OK so a second attempt to answer your question with a pure GDAL solution. Firstly, GDAL (Geospatial Data Abstraction Library) was originally just a library for working with raster geo-spatial data, while the separate OGR library was intended to work with vector data. However, the two libraries are now partially merged, and are generally downloaded and ...


5

Following a recent question, you may want to make use of the functionalities offered by the rgeos package to solve your problem. For reasons of reproducibility, I downloaded a shapefile of Tanzanian roads from DIVA-GIS and put it in my current working directory. For the upcoming tasks, you will need three packages: rgdal for general spatial data handling ...


5

In addition to @Etiennebr's answer, I'd go for an apply style loop (which is more R-ish, and uses less code for the same thing): library("raster") filenames <- list.files(path="", pattern="XYhectareTravelTimes_ez+.*shp") raster_cat = lapply(filenames, function(x) { travel <- as.data.frame(readShapePoints(x)) r <- rasterFromXYZ(travel[, c("x", ...


5

I've had some luck reading from and writing to layers. Specifically, I have code that will read a shapefile layer containing polylines and output the geometry of each feature to text files (used as input for an old model). name = layer.name() provider = layer.dataProvider() feat = QgsFeature() # Now we can loop through all the defined features ...


5

I've been playing with GDALRasterizeLayers this week and have a pretty good idea of what it is doing. By default, it will rasterise a pixel if the pixel centre is within the polygon. If there is nothing in the centre, it won't be rasterised, even if there are parts of a polygon within the pixel limits. To allow the rasterising to work the way you intend, try ...


4

Two things you could check: First make sure that your resolution is set correctly. This you do with the "Edit Current Grass Region" button. You mentioned that the original csv file had points every 40 km. If you want to stay with that, then assuming your points are in a projected coordinate system you should set the resolution to 40,000. If the points are ...


4

You could try to create a Voronoi diagram. It seems to work: If the Voronoi tool should fail on 75,000 points, try divide&conquer: Split the point layer into multiple smaller ones to make computation easier.


4

If you want to get zonal statistics for several features in one shapefile, you have to loop over the zonal_stats function. You can write the results of the loop for example to a dictionary. Below is the modified zonal_stats function together with a loop, looping over the input shapefile. As an output you get a Dictionary containing for each Feature ID the ...


4

These two comparable tools exist because ESRI has multiple license levels. Point to Raster (Conversion) is only available with the Advanced license. Feature to Raster (Conversion) is available with all of the license levels. Point to Raster allows you much more control over how multiple points are handled when multiple points fall within a raster cell. ...


4

Feature to raster will convert lines, points or polygon features to rasters, while polygon to raster will only convert polygons. http://resources.arcgis.com/en/help/main/10.2/index.html#//00120000002v000000 http://resources.arcgis.com/en/help/main/10.2/index.html#//001200000030000000 They both can handle polygons, which is why they are completing what you ...


3

This is a kludge but it does work - haven't found a way to go directly from points to raster yet (but am hoping someone gives a solution here!). Starting with a point grid (random points in the Serengeti from the Vector|Research tools|Random points tool): Create a polygonal grid of the same extent and cell size as the raster you'd like to have (this from ...


3

You have arcgis as one of your tags so I will answer from that perspective. The tool for converting shapefile features into raster is Feature To Raster. Alternatively, you may want to consider Exporting your map using one of the supported raster formats.


3

I've not tried it, but GDAL's gdal_rasterize should do the trick with its -3d option: gdal_rasterize -3d -tr 10.0 10.0 -l streams streams.shp streams.tif


3

According to the GDAL Proximity page: -distunits PIXEL/GEO: Indicate whether distances generated should be in pixel or georeferenced coordinates (default PIXEL). So you can specify the distances in pixels or in the unit of the coordinates you used to georeference the raster.


3

Here's a simple reproducible example. I give 2 approaches, one using mosaic/merge and another that just does the initial rasterize at the total extent of all shapefiles combined. The results are the same. Added based on Jeffrey Evans comment: You also need to consider what to do when you have overlapping polygons. If you want to apply a function (e.g. sum, ...


2

Go Raster -> Conversion -> Rasterize. Set a vector layer to process, a field with values and desired raster size.


2

Your error says as.integer(putvals). The R rasterize function can't work on Strings. You have to transform your data first. Something like this may work, but i would assign different ranks (ala 1,2,3,4,..) to your data. However i still get a (different) error for which i don't have an explanation. Maybe the size of your raster is incorrect... ...


2

This particular function does require a regularly spaced set of points. The error message is reporting that there are gaps in your data and it's not able to interpolate between the existing points to provide the value for the missing points. You need to see if R has a different rasterizing function that will interpolate to fill in the gaps, or find some ...


2

You could add a field to the lake shapefile called "value", and populate it with the value 1. In your Rasterize tool, set the value field to "value", and create your raster. Then just clip the raster using your min/max x & y values using the Clipper tool? Raster -> Extraction -> Clipper The output will be a clipped raster with 1 values for ...


2

With multiprocessing, for fastness! Has a little different output-formatting. #!/usr/bin/python import gdal, ogr, osr, numpy, sys from multiprocessing import Pool # Raster dataset input_value_raster = sys.argv[1] # Vector dataset(zones) input_zone_polygon = sys.argv[2] # Open data rast = gdal.Open(input_value_raster) shp = ogr.Open(input_zone_polygon) ...


2

gdal_rasterize is not a python module, but an exe file. You can not call it that easy inside the python console. See this blogpost on how to wrap the operating system around it: http://geoinformaticstutorial.blogspot.de/2012/11/convert-shapefile-to-raster-with-gdal.html import os os.system('gdal_rasterize -a ICE_TYPE -where \"ICE_TYPE=\'Open Water\'\" ...


2

This can be done in a two step process... Use Merge to combine all your polygons into one polygon (tool found in the Data Management / General toolbox) Use Feature to Raster to change the polygon into a raster (tool found in the Conversion / To Raster toolbox). These are both straightforward tools. The most complicated part with Feature to Raster is ...


2

Well, you have two potential issues: 1) "HIshp" is in a "UTM Zone 4" projection and the raster you defined is in a geographic projection (lat/long). You can use "spTransform" to reproject "Hishp" so that it aligns with "new_ras". 2) You need to define the attribute in "HIshp" that you want to represent the raster values (ie., rasterize(HIshp, new_ras, ...


2

First, reproject the vector data to WGS84 (Lat/Long degrees): HI_WGS84 <- spTransform(HIshp, CRS("+proj=longlat +elips=WGS84")) Then rasterize a new result: new_ras <- raster(nrow=1520, ncol=2288) crs(new_ras) <- crs(HI_WGS84) extent(new_ras) <- c(-159.816, -154.668, 18.849, 22.269) HI_popdens <- rasterize(HI_WGS84, new_ras, ...


2

It's telling you it doesn't like your values as int, they round to 0 and you can't have a 0 row, 0 column raster. That's because you're supplying the cell size and not the rows and columns. When you create a dataset it needs to know how many rows and columns it is, you then tell it how big the cells are in the geotransform: # 1. Define pixel_size and NoData ...


2

The tool works well. I modified slightly the code for producing only 3 raster (10, 20 and 30 Pixel Size) with a point shapefile with 5 features. import processing RasterPixelSize = (10.0,20.0,30.0) i=1 for rps in RasterPixelSize: processing.runalg("gdalogr:rasterize",\ "/home/zeito/pyqgis_data/point.shp",\ "id",None,1,rps,rps,6, ...


2

As you figured out, the column is not defined as 'Integer' or 'Real' type. You can use Field Calculator to add a new column of type integer and write an expression such as below to have a field you can use in conversion. toint("TEXTURA LA")



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