How to automate flooded area calculation and make report using R?

I have 3 shapefiles with me. They are a

  1. Flooded layer,
  2. District layer
  3. Village layer.

To estimate flooding village wise, I have to do intersecting the features and get the layer. Then I calculate the flooded layer.

Raw village shapefile contains the attributes ' Village_Name ' and ' Area '.

District layer contains ' District_name ' and ' Revenue_Circle '

After intersecting the area for the flooded layer is calculated as ' flooded_area '. So the intersected layer will have ' District_nam ',' Revenue_Circle ', ' Village_area ' and ' flooded_Area '.

After doing all these I have to convert all the attributes to excel file and using Pivot table all the data need to be sorted district wise. In the excel I have to remove underscore, change the field name, adding a percentage of the village area got flooded and display summation at the last and all these are done in separate sheets for each district.

Is there any automatic workflow for this in R if I have to do this every day?

Regards,
Gokul

Gokul:

Make a small reproducible example (see here) with a snippet of your data and showing the R code you are running to create the intersected layer.

You can do everything you have spelled out in R so Excel would be unnecessary.

1 Like

Currently I don't have any such information with me in R. I was doing in arcgis. So I thought to do in R. Let me see if I can create a sample problem in R.

Geocomputation with R might be a good start to transitioning from ARCGIS.

1 Like

What you describe can be decomposed to several smaller issues:

  • reading in several shapefiles: the district and village seem static, and flooding is changing daily
  • intersecting the flooding shapefile with districts and villages, and calculating derived metrics (area & share of are flooded)
  • producing a report in excel or what not
  • automating this workflow to run on regular schedule

All of these steps are doable in R, but have to be scripted mostly from scratch and are beyond the scope of a single post.

So doable yes, but not basic and it will require some investment of time to implement.

The open access Geocomputation with R book linked by @Ani should give you an idea (I am unsure whether it touches job scheduling, but for that topic do have a look at cronR package if on Linux or taskscheduleR if on Windows)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.