Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to develop a webportal which will display the images generated by a GIS software package. I my development I need to run gdal command inside php exec() function. but I don't know how to do this.

share|improve this question
Be VERY careful allowing PHP to call system executables (if you can, just don't). Read specifically '#12 Disabling Dangerous PHP Functions.' – dakcarto May 31 '12 at 18:18

it works under PHP 4, PHP 5. beside this you can use passthru command too.. passthru command execute an external program and display raw output.

exec — Execute an external program


string exec ( string $command [, array &$output [, int &$return_var ]] )

exec() executes the given command.

there is an example here. but they are complaining that it works a bit slow.


// gdal_translate converts GIS data
// in this case, simply copy a GeoTIFF with no transforms
$command = 'gdal_translate /tmp/in.tif /tmp/out.tif';

$t0 = microtime(true);
$t1 = microtime(true);

printf("%.1f seconds", $t1 - $t0);

i hope it helps you...

share|improve this answer
yeah, it works for me. thanks Aragon – Mehedi May 28 '12 at 9:24
@Mehedi - Please mark this as accepted if it indeed solved your problem. – Chad Cooper Jun 1 '12 at 14:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.