Yesterday I was helping a friend summarize some yield monitor data. We used QGIS to determine which yield monitor observations fell within certain study areas, saved this information to a CSV, and did further analysis of this data in R. This is a really common workflow for me, and today I’m going to share some data management tricks that make my life easier.
To the left is a snazzy visualization of how I might combine different data sources from OGRIP, farmers, and Web Soil Survey using QGIS and R.
Moving raster data, shape files, and CSV file through two different softwares can seem daunting, but project files make it pretty user friendly. I have some details about how to make project files in RStudio in the last post, and today I’m going to connect that to QGIS project files.
The first thing I do is make a new folder in my file directory. I put all my data sources in that folder before opening the data in QGIS. After doing my geoprocessing in QGIS, I export the CSV file with the linked data sources and save it to that file folder.
In QGIS I also make sure I save my project file. This works really similarly to a project file in RStudio. It saves your layer style settings and your map composers. Here’s a link to a great video about QGIS Project Files. If I find that I’m missing a data type or want to visualize something quickly, I can just reopen the project file at any point in my analysis. This saves a lot of time compared to having to open the software and then each data file again.
Then I make an RStudio project file (more details in my last post) here in the same file folder. This makes the working directory for R the same place I’m saving CSV files from QGIS. As I update files in QGIS, I can easily read them into R. I can also write CSV files from R to this folder and then open them in QGIS.
Keeping all my data files in a folder with my QGIS project file and RStudio project file makes it really easy to send all my files to collaborators. I zip the file and email it or put it on a flash drive as is and can open the project files (assuming the other computer has the right software installed) and immediately start working.
Is this the only way to organize your data? Nope. But it is a great starting point if you’re feeling overwhelmed or just getting into QGIS and R. I’m always looking for ways to make this process easier, so share further data management thoughts in the comments!