You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the hyRefactor::clean_geometry function to clean up polygon fragments but I keep getting an error message:
Error : The mapshaper node library must be installed and on your PATH. Install node.js (https://nodejs.org/en/) and then install mapshaper with: npm install -g mapshaper
I have installed node.js and run npm install -g mapshaper but still get the error after restarting R and rerunning the code.
# Clear the workspace and reset graphics ----
rm(list= ls())
dev.off()
#> null device #> 1# Load necessary libraries ----
library(tidyverse)
library(nhdplusTools)
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(ggspatial)
library(rmapshaper)
library(hyRefactor)
# 1. Define the starting point (pour point) ----start_point<- st_sfc(st_point(c(-78.336, 38.976)), crs=4269)
## 1a. Snap point to the nearest NHDPlus flowline ----trace<- get_raindrop_trace(start_point)
## 1b. Use the intersection point as the pour point ----snap_point<- st_sfc(st_point(trace$intersection_point[[1]]),
crs=4269)
# 2. Retrieve NHDPlus COMID for the snapped point ----start_comid<- discover_nhdplus_id(snap_point)
# 3. Navigate and extract upstream tributary flowlines ----flowline<- navigate_nldi(list(featureSource="comid",
featureID=start_comid),
mode="upstreamTributaries",
distance_km=1000)
# 4. Download and subset NHDPlus data for the flowlines ----subset_file<- tempfile(fileext=".gpkg")
subset<- subset_nhdplus(comids= as.integer(flowline$UT$nhdplus_comid),
output_file=subset_file,
nhdplus_data="download",
flowline_only=FALSE,
return_data=TRUE, overwrite=TRUE)
#> All intersections performed in latitude/longitude.#> Reading NHDFlowline_Network#> Writing NHDFlowline_Network#> Reading CatchmentSP#> Writing CatchmentSPflowline<-subset$NHDFlowline_Network# Define the NLDI feature list for the starting COMID ----nldi_nwis<-list(featureSource="comid", featureID=start_comid)
# 5. Delineate the basin for the snap point ----basin<- get_split_catchment(snap_point, upstream=TRUE)
basin$ID<-'Strasburg'basin<- clean_geometry(basin, ID="ID")
#> Error : The mapshaper node library must be installed and on your PATH.#> Install node.js (https://nodejs.org/en/) and then install mapshaper with:#> npm install -g mapshaper
I am trying to use the
hyRefactor::clean_geometry
function to clean up polygon fragments but I keep getting an error message:Error : The mapshaper node library must be installed and on your PATH. Install node.js (https://nodejs.org/en/) and then install mapshaper with: npm install -g mapshaper
I have installed
node.js
and runnpm install -g mapshaper
but still get the error after restarting R and rerunning the code.Created on 2024-08-05 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: