Calculating attributes edges with vectors and percent throws error
ellend999 opened this issue · comments
Hi I am using OpenSTARS with GRASS 7.6.1.
I was successfully able to run the whole process with your demo data but when I try it with my own data, it works fine until I get to calculating attributes of edges.
I am trying to get a percentage of mining (polygon).
calc_attributes_edges(input_vector = c("disturb"), stat_vect = c("percent"), attr_name_vect = c("minedpct"))
When I run that I get the following error:
Intersecting vector attributes ...
WARNING: Values in column will be overwritten
Error in setnames(dt.dat, "a_edge_cat", "edge_cat") :
Items of 'old' not found in column names: a_edge_cat. Consider skip_absent=TRUE.
In addition: Warning message:
In system(syscmd, intern = intern, ignore.stderr = ignore.stderr, :
running command 'db.select.bat sql="select a_edge_cat, area, b_minedpct from temp_inters"' had status 1
It appears to be looking to rename columns that don't exist.
I appreciate any help. Please let me know if you need more information.
Ellen
Dear Ellen
It is difficult to find the error without seeing your data.
The first thing the check is if in the colum "minedpct" really exist in the vector file "disturb" (exact spelling).
Also, I am currently updating a few functions and calc_attributes_edges is one of them. You could try to install the development version of the package from GitHub using:
devtools::install_github("MiKatt/openSTARS", ref = "dev")
Please let me know if this helps.
All the best, Mira
Thank you for the response. From what I understand shouldn't the code should be creating the field "minedpct." It does not need to be in my vector file. In your example data your landuse vector did not have a "landuse" attribute, it was called "lu" in the shapefile. I did try adding a field called "minedpct" to my vector data but the same error occurred. Perhaps I missed a step somewhere that creates that field? I won't have the opportunity to install the development version until early next week. Hopefully the changes you made will solve the issue.
For vector files, attr_name_vec is the attribute column to calculate the statistics from (see help). That means you need to tell the function from which column(s) you want to calculate attributes.
For raster data, this is different because there is just one value. Here, attr_name_rast gives the new column names for the attribute.
What kind of data do you want to use, i.e. what are the column names in your vector file "disturb"?
This is independent of the version of openSTARS you use. Nevertheless, it might be better to use the newer development version (that will be put on CRAN soon).
Thanks that would be useful information to add to your demo instructions on your main page. I figured out what was going on. The field is case sensitive so I was putting in "minedfill" instead of "MinedFill". That got me past the error but now its running (has been running for 6 hours) which doesn't make much sense since its a small dataset. I will try the development version once its available and see if there is an improvement.
Edit: The code eventually errored out but I figured out it was due to a null value in the attribute table. When I ran it with a test subset with no null values it completed successfully.