Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm manipulating mapfiles through mapscript. Setting layer attribute values like the opacity works like this:

$layer = $map->getLayer('layername');
//set an attribute value
$layer->set('opacity', 80);

But now I want to set the data attribute as well, I assumed it functions like this:

$layer = $map->getLayer('layername');
//set an attribute value
$layer->set('data', '/path/to/my/shape/file.shp');

But nothing happens, i.e. an image is constructed but it's empty because no data was inserted.

How can I set the data string?

Thank you

PS: I'm using Mapserver 5.0.3 + Mapscript 4.10

EDIT: I used the map.getLayer() method instead of the getLayerByName method. While testing on the opacity attribute, I had a mapfile with only one layer, so the getLayer('loadlines') did return a (but in this case the last and correct) layer.

share|improve this question
add comment

1 Answer

$layer = $map->getLayerByName('layername');
//set an attribute value
$layer->set('data', '/path/to/my/shape/file.shp');

or

$layer = $map->getLayer('layer_index'); //integer!
//set an attribute value
$layer->set('data', '/path/to/my/shape/file.shp');
share|improve this answer
add comment

Your Answer

 
discard

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.