0.field buffer.R
0.field buffer.R | 0.field buffer.py |
---|---|
library(sf) | import geopandas as gpd |
Loads a library for handling geospatial data, including working with shapefiles. In the Python code, gpd is an alias for the geopandas library Using the alias simply reduces typing and improves code readability. | |
setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) |
|
RStudio defaults to a global working directory, which means file paths must be specified explicitly. Python defaults to the folder where the source code is located. Jupyter Notebook defaults to where you launch the notebook server.
The original file path was To avoid referencing This way, the R program can run without requiring the full path in filenames. | |
This code:
R uses In Python, a backslash ( Also, note that the dots in | |
Writes the buffered data frame to a new shapefile. I added |