ateucher / rmapshaper

An R wrapper for the mapshaper javascript library
http://andyteucher.ca/rmapshaper/
Other
200 stars 13 forks source link

mapshaper cannot find geojson file (username with spaces?) #107

Closed grcolli closed 4 years ago

grcolli commented 4 years ago

shape_municipios_simp <- rmapshaper::ms_simplify(shape_municipios, sys = T) Error: [o] Command expects a single value. Received: C:\Users\Guarino R. Colli\AppData\Local\Temp\RtmpScK7dh\file41301ed349d8.geojson Run mapshaper -h to view help Error: Cannot open "C:\Users\Guarino R. Colli\AppData\Local\Temp\RtmpScK7dh\file41301ed349d8.geojson"; The file doesn't seem to exist.

From other forums, the issue is related to a username (and directory names) with spaces. Is there a way around this, other than creating a new user? Thanks, Guarino.

[output of Sys.getenv() deleted by @ateucher]

ateucher commented 4 years ago

@grcolli thanks very much for this report. I think I've fixed it, if you get a chance can you please try out the development version by installing from here:

# install.packages("remotes")
remotes::install_github("ateucher/rmapshaper")
library(rmapshaper)
grcolli commented 4 years ago

Hi Andy, thanks a lot for your prompt response. I reran the code but apparently the issue was not solve (see below). I'm ready to help and provide any additional info deemed necessary. Cheers, G.

remove(list = ls())

Load packages

library(iterators) library(magrittr) setwd("~/GitHub/COVID-19")

Make sure working directory has been correctly set before running this!

my.dir <- paste(getwd(), "/", sep = "")

Load shape files

shape_municipios <-

  • rgdal::readOGR(paste(my.dir, "data/shape_municipios/BRMUE250GC_SIR.shp", sep = ""),
  • stringsAsFactors = F) OGR data source with driver: ESRI Shapefile Source: "C:\Users\Guarino R. Colli\Documents\GitHub\COVID-19\data\shape_municipios\BRMUE250GC_SIR.shp", layer: "BRMUE250GC_SIR" with 5572 features It has 2 fields

    Simplify shape files with rmapshaper

    Make sure mapshaper is installed in system

    shape_municipios_simp <- rmapshaper::ms_simplify(shape_municipios, sys = T) Error: [o] Command expects a single value. Received: C:\Users\Guarino R. Colli\AppData\Local\Temp\RtmpeAV1bp\file5cd4186c1b71.geojson Run mapshaper -h to view help Error: Cannot open "C:\Users\Guarino R. Colli\AppData\Local\Temp\RtmpeAV1bp\file5cd4186c1b71.geojson"; The file doesn't seem to exist.

grcolli commented 4 years ago

Andy, my bad. After installing the development version of rmapshaper, the code ran smoothly! Thanks a lot. Best, G.

Simplify shape files with rmapshaper

Make sure mapshaper is installed in system

shape_municipios_simp <- rmapshaper::ms_simplify(shape_municipios, sys = T) [i] Snapped 40638 points [simplify] Repaired 23 intersections [filter] Retained 5,572 of 5,572 features [o] Wrote C:\Users\Guarino R. Colli\AppData\Local\Temp\RtmpkhLjym\file62482e77698e.geojson

ateucher commented 4 years ago

Oh excellent! I was scratching my head, as I was sure my patch would fix it. Thanks for trying again and reporting back

ateucher commented 4 years ago

One more unrelated thought @grcolli - it's generally a bit risky to post the output of Sys.getenv() as many people store sensitive info such as authorization tokens there. Yours looked safe enough, but I hope you don't mind I removed it from your comment.

grcolli commented 4 years ago

Thanks Andy. Will be more careful next time!