Coder Social home page Coder Social logo

Comments (4)

giswqs avatar giswqs commented on June 21, 2024

I just tested it, and everything seems to work fine. Your CWD and --wd in the output are different directories. They are supposed to be the same. Not sure why they are different on your computer.

image

from whitebox-python.

arojas314 avatar arojas314 commented on June 21, 2024

Ok, that makes sense. Thanks for the quick response!

Just to follow up:
The working directory is my project directory, and then I use a relative path to the data folder where all the data is. Is that not correct? I am working with a lot of data in separate directories, should I explicitly set the wbt.set_working_dir() each time I run a whitebox function?

from whitebox-python.

giswqs avatar giswqs commented on June 21, 2024

You can either provide absolute paths to input files or use wbt.set_working_dir("/absolute/path/to/wd"), and then you can use relative paths

I noticed that every time a tool is executed, the working directory is changed to the wbt exe path. Therefore, you can no longer use os.getcwd() to set the working directory. This is the behavior of whitebox_tools.py. It needs to be fixed by @jblindsay. os.chdir(self.exe_path) is used 10 times in the script. One potential solution is to reset the working directory at the end of a wbt function.
https://github.com/jblindsay/whitebox-tools/blob/master/whitebox_tools.py#L171

cwd = os.getcwd()
os.chdir(self.exe_path)

# at the end
os.chdir(cwd)

from whitebox-python.

arojas314 avatar arojas314 commented on June 21, 2024

This resolved my issue completely. However, I still cannot use relative paths after I use wbt.set_working_dir("/absolute/path/to/wd"). I was able to work around this, but here is a quick example of when using a relative path after setting the working directory fails:

cwd = os.getcwd()
wbt.set_working_dir(cwd)

wbt.clip_lidar_to_polygon(
   i="./data/lidarFile.las",
   polygons="./airsheds/TEAK_airshed.shp"
   output="./data/lidarClipped.las"
)

Thanks!

from whitebox-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.