Skip to content

QAWalker/GIStoolkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GIStoolkit

GIStoolkitis a collection of handy R functions for accomplishing common GIS tasks.

Installation

You can install the development version of GIStoolkit from GitHub with:

remotes::install_github("QAWalker/GIStoolkit")

Load the package into your R session

library(GIStoolkit)

Functions

1. Interactive Point Selection

get_clicked_point() launches an interactive map in your viewer or browser and allowing the user to save the clicked point. You must click the marker icon on the left to add a point.

my_point <- get_clicked_point()

2. Interactive Raster Cropping

click_to_crop(raster_obj, mask = TRUE)allows you to define a study area visually.

The maskparameter determines the output:

  • mask = TRUE(Default): Launches a polygon tool. The result is clipped to the exact shape, and pixels outside are set to NA.
  • mask = FALSE: Launches an extent tool. The result is cropped to a rectangular bounding box.
r <- terra::rast("my_raster.tif")

# To get a polygon shape:
polygon_crop <- click_to_crop(r, mask = TRUE)

# To crop to a rectangular defined by the extend of the points:
rectangle_crop <- click_to_crop(r, mask = FALSE)

# Save Cropped Results
terra::writeRaster(polygon_crop, filename = "path/to/save/polygon_cropped_raster.tif")

terra::writeRaster(rectangle_crop, filename = "path/to/save/rectangle_cropped_raster.tif")

About

Internal GIS Tools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages