【发布时间】:2021-09-09 03:01:23
【问题描述】:
我有一个 shapefile 的边界框。我想用这个 bbox 来剪辑一个我同时拥有光栅和 shapefile 的图像。
我尝试使用 gIntersection 和裁剪(见下文)。不确定我是否需要将 bbox 转换为多边形来执行此操作。
raster = county raster
plot_parcel_bb = bbox
county_shp = county shape
#4.Use bounding box to clip the appropriate county imagery tile (raster&vector in QGIS)
#Check class
class(raster)
class(plot_parcel_bb)
#Check extents
extent(raster)
extent(plot_parcel_bb)
#set the raster image extent to match the shp extent
new_raster<- setExtent(raster, ext = county_shp)
extent(new_raster)
#check the raster and plot parcels crs
st_crs(new_raster)
st_crs(plot_parcel_bb)
#make sure both crs's match
crs(new_raster) <- "EPSG:4326"
st_crs(new_raster)
#this does not overlap
cropped<- crop(new_raster, extent(plot_parcel_bb), filename = "cropped", snap = 'near')
我是否需要覆盖图像 shapefile 和光栅并从中剪裁 bbox?也许我从错误的地方开始。我不确定要先采取哪一步。
我在这个网站的正确位置吗 - https://datacarpentry.org/r-raster-vector-geospatial/11-vector-raster-integration/
谢谢
【问题讨论】:
-
请参阅
raster::crop--- 或者,如果您想要更详细的答案,请编辑您的问题以更清楚地解释您的目标以及您遇到的问题,包括 minimal,独立的、可重复的示例. -
会的,谢谢罗伯特
标签: r crop intersection bounding-box clip