= Add Layer, Query and Reproject = Here's a small example which: * opens a mapfile * adds a new layer * queries new layer * reprojects output map * draws and saves to file Example based on http://dl.maptools.org/dl/omsug/osgis2004/php_mapscript_mum2.ppt in response to http://n2.nabble.com/Problems-with-MapScript-and-setProjection-tt2291579.html#none {{{ set("name", "foo"); $layer->set("status", MS_ON); $layer->set("data", "path/to/file.shp"); $layer->set("type", MS_LAYER_POINT); $layer->setProjection("init=epsg:4326"); $layer->set("template", "ttt"); $layer->set("dump", "true"); // add new class to new layer $class = ms_newClassObj($layer); $class->set("name", "foo"); // add new style to new class $style = ms_newStyleObj($class); $style->set("symbol", 2); $style->set("size", 8); $style->color->setRGB(255, 0, 0); // create new rect to query against the new layer $rect = ms_newRectObj(); $rect->setExtent(-95, 40, -50, 60); // query new layer $layer->queryByRect($rect); // set projection of output map $map->setProjection("init=epsg:42304", MS_TRUE); // draw $image=$map->drawQuery(); $image->saveImage("/tmp/out.png"); ?> }}}