I wanted to know if anyone has experience working with WISE soil database, I am trying to process world soil data which is downloaded from here


After I downloaded the folder, there are 5 files present:

HWSD (Microsoft Access database)
HWSD_META (Microsoft Access database)

I have not really worked with raster data present an an MS Access database. What I need to do is for a given lat long, extract all the data from the above soil database. How do I go about doing this in R? Is there an online tutorial?

3 Answers 3


The r package 'hwsdr' gives a reduced resolution version with fewer available variables. Here is a simple solution if you have MS Access, or if you download a free MDB viewer (e.g. https://helpdeskgeek.com/free-tools-review/open-access-database/). Open the .mdb database, and open the 'HWSD_SMU' table for soil types. Select and copy the whole 'MU_GLOBAL' column (the global raster cell ID's) and paste in a new spreadsheet; do the same with 'SU_CODE', which is the code for soil types (summarised in the 'D_SYMBOL' table), pasting it in the second column. For other soil variables, see the 'HWSD_DATA' table and you can do the same for each variable you need: two columns, the left being the cell ID and the right being the relevant variable. Save the spreadsheet as a CSV.

Now in R:


setwd("your chosen files location")

rID = raster("hwsd.bil") #read the raster file downloaded from HWSD, making sure all 4 files are in the same folder
#projection optional, not really needed for this:
proj4string(rID)="+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0" 
plot(rID) #check it plots the world
rIDcrop = crop(rID, extent(10, 40, -35, -15))#specify lon/lat extent to clip to your study area
plot(rIDcrop)#check your area plots correctly
df = read.csv("HWSD_data.csv")#the 2-column file you saved from the first steps

#now reclassify the values in your raster according to the chosen variable 
rIDf = reclassify(rIDcrop, df)  
plot(rIDf) #check it makes sense

writeRaster(rIDf, "variableName.asc", format="ascii")#I just prefer ASCII 

Wow, leave it to soil folks to put raster attribute data into an access database. So, I imagine that the raster has values matching a key value, then associated with tables of the 20 soil properties, in the MS database. Look at the metadata (why it is not in the same ms file is beyond me) and figure out what the key value is.

You can connect to an MS database using dbConnect in odbc and query the database for whatever joins you need. You may need to install the appropriate driver from Microsoft (eg., Microsoft Access Database Engine redistributable) to make sure you are 64-bit compliant. You can use the odbcListDrivers function to check and see if the drives are visible. If you have Access, you could also export the tables as flat files (eg., csv).

Personally, I would take a reclassification approach, where raster values are reassigned to the associated attribute level or value from the table, rather than trying to manage a single RAT with the attributes.

  • Thank you. I will note these pointers down and try to work my way through.
    – 89_Simple
    Jun 3, 2020 at 21:45
  • I found one tutorial here. The only issue is that they convert the access database to sqlite format and then process that in R. I can't do the first part and still looking for some tutorials on connecting the access db to R css.cornell.edu/faculty/dgr2/_static/files/R_PDF/R_HWSD.pdf
    – 89_Simple
    Jun 4, 2020 at 21:31

For anyone looking for answers, following is a nice package to work with HWSD in R


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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