piotrass077
piotrass077

Reputation: 1

What does "~" mean in gdal?

I'm new in programming and I try to use gdal library for Python. I would like to execute gdalinfo command, but I don't know what "~" mean in "gdalinfo somedir/somefile.tif" example. Could you explain it to me?

Upvotes: 0

Views: 103

Answers (1)

cdarke
cdarke

Reputation: 44354

I assume you are looking at Obtain Latitude and Longitude from a GeoTIFF File, the line is:

dalinfo ~/somedir/somefile.tif 

Here the ~ is UNIX style shell expansion and is a shortcut for the current user's home directory. The nearest equivalent on Windows is the environment variable %HOMEDIR%.

On UNIX style systems it is also represented by the environment variable value $HOME.

The user's home directory is the current directory ("folder", if you must) used when you first logon. On UNIX systems it holds files containing user preferences and start-up files, often using filenames beginning with a dot, for example .profile. You won't see those using ls, you need ls -a. The home directory on Windows is used, but many end-users are not aware of it, although some software products (particularly portable ones) use it.

The ~ generally means something completely different in a programming language, and cannot be used as part of a filename without invoking a shell.

In Python, to get the home directory you would need to read the environment variable, for example os.environ['HOME'].

Upvotes: 3

Related Questions