Cropping field into small-plots using FieldImageR

60 views
Skip to first unread message

Tej Shahi

unread,
Nov 6, 2020, 12:23:11 AM11/6/20
to FIELDimageR: A R package to analyze orthomosaic images from field trials.

Hi All:

Hope you all are doing well. I am new in FieldImageR and want to use it to split a field-image (multispectral)  into a small plot-images (using polygon shape) for further analysis with deep neural networks. I have attached an example image here with. Is there any specific function in FieldImageR?


The polygons are displayed in black box:


Many thanks in advances!

Regards

Tej

Tej Shahi

unread,
Nov 6, 2020, 12:46:15 AM11/6/20
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
field with polygon.jpg

fmatias

unread,
Nov 6, 2020, 4:46:08 PM11/6/20
to FIELDimageR: A R package to analyze orthomosaic images from field trials.
Hi Tej,

I am not sure if it is what are you looking for but the function below was presented by Roberto Fritsche-Neto to clip images using each plot shape. 

#clipping raster by plots - a function
plot_clip <- function(ortho, shape){
  plot_raster <- list()
  for (i in 1:nrow(shape)) {
    cat("plot_", i, " ")
    p <- shape[i,]
    plot_raster[[i]] <- crop(x = ortho, y = extent(p))
    plot_raster[[i]] <- mask(plot_raster[[i]], p)
    names(plot_raster)[i] <- shape$plot[i]
  }
  return(plot_raster)
}

# clipping all seeds in single shots
rasterbyplots <- plot_clip(mosaic, ShapeFile)

Hope it helps...!!!
Best,
Filipe

Tej Shahi

unread,
Nov 7, 2020, 9:02:42 PM11/7/20
to FIELD...@googlegroups.com
Hi Filipe:
Thanks for code! it works for me.

Regards
Tej

--
You received this message because you are subscribed to a topic in the Google Groups "FIELDimageR: A R package to analyze orthomosaic images from field trials." group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/FIELDimageR/5Wa1IVmhsyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to FIELDimageR...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/FIELDimageR/dfa89741-9963-4d91-9814-7f8d7bd3ddafn%40googlegroups.com.


--
==============================
Tej Bahadur Shahi
Lecturer
Central Department of Computer Science and IT
Tribhuvan University, Kritipur
Kathmandu, Nepal
Mob: 9851176057
Office: 01-4332619

Reply all
Reply to author
Forward
0 new messages