Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

If I load the original .csv file, I then have a map of the African continent represented by 14069 data points covering it at 40x40km resolution. Each data point shows solar radiation means across the year, (jan, feb, etc).

What I want to be able to do is convert that vector into a raster using GRASS.

What I have managed to do already, is import the .csv (tab delimited) file into the GRASS mapset using v.in.ascii. However, when I try use v.to.rast.constant to convert that vector into a raster, I get a solid square covering Africa, that cannot be edited. I.e. there is no data from the vector within the created raster.

What am I doing wrong?

This work is for my masters thesis and I'm constantly working on it.

Thanks!

share|improve this question
    
This is unlikely to be a full grid of points, unless its dimensions are 11 by 1279 (or 1 by 14069)! Could you tell us more about the pattern of locations? (Often, continental data like these are obtained on a grid that consists of perfect rectangles only in one specific projection, so knowing that projection can be critical for the conversion.) The question, answer, and comments at gis.stackexchange.com/questions/20018 may be helpful. –  whuber Aug 27 '12 at 14:12
    
I am using the csv file data taken from en.openei.org/datasets/node/494 - "Solar- monthly and annual average direct normal (DNI), global horizontal (GHI), latitude tilt, and diffuse data and GIS data at 40km resolution for Africa from NREL" This csv file has 41069 (not 14069 as I first said). When I load that csv file into QGIS as a delimited text layer, with comma separator. This gives me a map of Africa with 41069 data points covering it. I then use GRASS (v.in.ascii) to import a text file into the mapset. This works. But I can't use v.to.rast.const. to make a raster of that text file –  Liam Aug 27 '12 at 22:25
    
because the raster it makes is just a massive pink square covering the whole extent of Africa... –  Liam Aug 27 '12 at 22:34
    
I also don't know how to use v.to.rast.constant. This should be able to take the input vector map (with all 41069 solar values). Raster value (for use=val) = 1. When this runs I get a large pink square covering my entire map. Right clicking the raster layer says that colour map's value is 1/1 and both are pink. When I assign 5 values (1-5) for the colour ramp and click run, the raster changes to the first colour value (blue in this case, value:1). Looking at the metadata tab MAX_VALUE: 1.000000, and MIN_VALUE: 1.0000. I don't know what I've done wrong here... –  Liam Aug 27 '12 at 22:50

2 Answers 2

up vote 3 down vote accepted

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 Lat/Lon then the cell size should be about 0.4 (4/10ths of a degree).

Next, I doubt that you want to use v.to.rast. That's for making a raster with individual pixel values matching the individual point values. (BTW, when you set use=val and value=1, you're telling grass to set all pixels to a value of 1. Not what you want...)

A better option might be to import the points directly into a raster using r.in.xyz. Of course, you'll need to create separate rasters for each month. The "Column of data values" will be one of the columns in the ascii file with the data for one of the months. And for the "Statistic" you'll want "mean".

HTH,

share|improve this answer
    
Hi, thanks so much. I don't have v.in.xyz loaded in GRASS. Is there a plugin that I need to download? –  Liam Aug 28 '12 at 9:20
2  
Hi, it worked! I used the Edit Current Grass Region, selected the extent of South Africa, and made cell width/height values 0.4 like you suggested. I then used v.to.rast.attr and selected the annual radiation as the attribute field. I am saving all my work, and writing down how we got this to work. Thanks again! –  Liam Aug 28 '12 at 9:40
1  
Just to clarify how I did it: 1) load delimited csv file. 2) open mapset. 3) run v.in.ascii. 4) Edit Grass Region Button - drag area extent (South Africa in my case), cell width/height = 0.4. 5) run v.to.rast.attr, with attribute field = the column I wanted to display. DONE! –  Liam Aug 28 '12 at 10:13
    
Is there any way to use r.in.xyz in qgis (1.8)? I can't find this function in Sextante toolbox. –  Miro Jun 26 '13 at 22:59

Make sure to zoom in enough, since it sounds like you're creating a large raster and individual points can be hard to spot if the field used for rasterisation has low values. Marking the whole layer as translucent can help too, since then you can check if it really is completely blank by zooming on one of the vector points and toggling that layer's visibility.

share|improve this answer
    
I don't manage to create the raster. –  Liam Aug 27 '12 at 12:08
    
I use v.in.ascii to import the text file into a vector format within GRASS. I then want to convert those data points (of solar radiation) into raster squares covering the whole of africa, but using v.to.rast.contant doesn't work (it gives me a huge pink square covering africa.) (That's problem one) Is there a way I can clip the original vector file to only include data for South Africa? (Problem two) The dataset I am using is crashing my PC constantly –  Liam Aug 27 '12 at 12:12
    
Make sure you pick the right attribute column for rasterisation. As for clipping, there are many ways, but this is a separate question. –  lynxlynxlynx Aug 27 '12 at 13:03
    
Hehe. Are you able to answer either of them? –  Liam Aug 27 '12 at 17:28
    
Rasterisation works for me. –  lynxlynxlynx Aug 27 '12 at 17:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.