10 Easy steps for converting mxd to map & sld

Pre-reqs: arcmap, mapserver (with PHP mapscript), webserver (with PHP support)

1. Load the layers and set the colourings and any filters you want into the mxd.
2. Download Amein! from sourceforge. Follow the instructions to add into arcmap
4. Once loaded, run amein! and fill out the dialog boxes (some are required)
5. Save and open the folder containing the generated map file
6. Open a text editor and create SLD.php. Paste the following ,

< ?php
// Load mapscript
dl("php_mapscript_44.dll");
// Create map object
$oMap = ms_newMapObj("C:\file\slip.map");
// Call the SLD output
$SLD = $oMap->generateSLD();
// Output
echo $SLD;
?>

7. Save SLD.php to a web accessible directory. Browse to that URL in your browser. (eg. http://localhost/sld.php)
8. Some text should be written to the screen in an unformatted manner. Right click inside the browser window and click ‘View Source’
9. Tada, the SLD. Select all and save contents to file, SLD.xml will do.
10. Open SLD.xml and check contents. While generateSLD does work quite well, on occasion it can struggle with things like Literal filter attributes. Have a quick glean over it to make sure all the tags are closed and it validates.
11. Add &SLD=http://path.to/your/sld.xml to your Mapserver query string and check the results.

Who said things always had to be done the hard way? :) These steps are particularly useful for further splitting the SLD into separate layers for use in Geoserver (dont get me started on WMS-SLD for gs :| ).

Hope this helps some people out there. Amein! is particularly good for converting a layer with a stack of class definitions. Ive done one with 45 class’es for one layer and it outputted the map file correctly, with the classification still in tact. Very nifty util, enjoy.

2 thoughts on “10 Easy steps for converting mxd to map & sld”

  1. I have now downloaded the amein_101.dll. Would someone please tell me steps in which I can add this to the arcmap?

    Many thanks

    Kaveh

Comments are closed.