2

I realize this isn't a geographic question as I'm not trying to make this into a geographically placed image. But I hope you all will know how to do this.

I want to make a raster from scratch. I have a database that I would like to be able to query and display the results as a sort of color map. I can figure out how to do the math and raster calculating, but I can't figure out how to make a raster. I expect that I need to add a couple of fields for the x and y coordinates, then give each record a value. Just 1s and 0s to begin with.

I work with ArcGIS, Oasis Montaj, and Microsoft Access at work all day, but I'd like to do this in QGIS and whatever other tools are necessary. I have spent almost no time with QGIS but would like to learn and work with it on my own projects. But I need to point in the right direction for this one.

Thanks

5

The simplest way I can think of for your situation would be to output the data as an Ascii Raster. Write an SQL query to dump the relevant value for each row of your database into a space delimited stream to a simple text file. Then add some header lines, give it the extension '.asc' and your task is done.

The advantage of this approach is that you don't need to get bogged down in coordinate systems or adding xy fields etc. You header takes the form:

NCOLS xxx
NROWS xxx
XLLCENTER xxx | XLLCORNER xxx
YLLCENTER xxx | YLLCORNER xxx
CELLSIZE xxx
NODATA_VALUE xxx

The first two lines just define the shape of your raster based on the data values. The rows here won't necessarily equate to your rows in your database - it depends on how your database is set up and you'll understand that best. When you create your SQL output, just export the value you will use for representation. You can ascribe a colour later so this doesn't matter too much at this stage. Set the next two lines to zero for either XLLCenter or XLLCorner (it's either or not both and defines where the data point is in relation to the raster cell - for you it doesn't matter but I'd go will Center). Your CELLSIZE again doesn't matter and I'd set it to '1'. A common value for NoData is -9999. Now you have an ascii raster you can use QGIS to convert it to a TIFF or add a colour pallet etc.

You could achieve a similar result without GIS and there are hundreds of ways to do this but the above solution should meet you need in a very simple way.

  • That's perfect. Thank you very much. Now I can begin to turn my database into an image. – cndnflyr Aug 26 '13 at 13:56
  • can you project an ascii raster? – user32882 Mar 13 at 15:26
  • Of course. Note the header above - which does much the same as a world-file, though you may well have to tell your GIS what coordinate system these values refer to. However you don't need to keep it as an ascii when you reproject, as you can decide the output format (perhaps a TIFF or PNG, for instance) – MappaGnosis Mar 13 at 15:36
1

try GMT, it's quite easy to create rasters as well as plot them as high quality maps, I'd say it's much more flexible (ie. working on details) than the software you mentioned (I've worked with all of them for a long time), and it's free. GRASS is a very good complement also. Check this out for one example: http://casoilresource.lawr.ucdavis.edu/drupal/node/102

Hope this helps,

  • That is helpful, thanks. Making the transition from Arc to Opensource is rather confusing. I find I'm always trying to figure out which tool fits where and what part of Arc it compares to. Especially with so much overlap. I had looked at GMT before, but the lack of a GUI intimidated me (another Arc user sideffect). I'll look into it some more. Thanks – cndnflyr Aug 26 '13 at 13:54
1

If you have the x-y coordinates and a specific value for each location (i.e. "z"), then the easiest way would be to turn your XYZ Text file (optimal is *.csv) into a grid with SAGA GIS. In the Module "Import/Export - Grids" you can choose "Import Grid from XYZ". As it lets you define a cell size, you should already know this ahead.

  • Thanks a lot for this. I hadn't come across this program yet. – cndnflyr Nov 29 '13 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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