<br><br><div class="gmail_quote">On Sun, Feb 13, 2011 at 4:36 PM, Richard Duivenvoorde <span dir="ltr">&lt;<a href="mailto:rdmailings@duif.net">rdmailings@duif.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div></div><div class="h5">Mohammed Rashad wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How to render a shapefile to an image file so that it can be reused on a web page.<br>
Anyone please send a me a minimal code or tell me where and what to modify. I looked src/mapserver folder but I cant get the code for it<br>
<br>
Atleast please tell me the file to modify to render a vector file(shape) to an image file<br>
</blockquote>
<br></div></div>
Hi,<br>
<br>
you&#39;re not very clear what exactly you want.<br></blockquote><div>I am trying to build an online shapefile viewer using qgis as a backend. for that i need to render qgis output to a image(.png) file</div><div>I cannot use QgsMapCanvas class because it requires QApplication I cannot use any class from qgis_gui</div>

<div>but qgis_core can be used.</div><div><br></div><div><br></div><div><div> QgsVectorLayer * mypLayer = new QgsVectorLayer(myLayerPath, myLayerBaseName, myProviderName);</div><div>  QgsSingleSymbolRenderer *mypRenderer = new QgsSingleSymbolRenderer(mypLayer-&gt;geometryType());</div>

<div>  QList&lt;QgsMapCanvasLayer&gt; myLayerSet;</div><div>  mypLayer-&gt;setRenderer(mypRenderer);</div><div><br></div><div>  if (mypLayer-&gt;isValid())</div><div>  {</div><div>    cout &lt;&lt; &quot;Layer is valid&quot;;</div>

<div>  }</div><div>  else</div><div>  {</div><div>    cout &lt;&lt; &quot;Layer is NOT valid&quot;;</div><div>    return;</div><div>  }</div></div><div><br></div><div>the following code works for me in Wt. It prints layer is valid or invalid according to the parameters to QgsVectorLayer()</div>

<div>can I set mypLayer-&gt;setRenderer of the above code to an image file so that rendering occurs on a image file of my choice?</div><div><br></div><div>It hope now the problem is clear.Now can you help me?</div><div><br>

</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
But, if you want a one time imagefile of a map from a shapefile, use &#39;Save as Image&#39; from the File menu.<br>
<br>
If you want to do some python coding for a plugin, please have a look in to for example the &quot;Html Image Map plugin&quot;, that one saves an image from current map. Minimal code from Python console in a running qgis:<br>


<br>
qgis.utils.iface.mapCanvas().saveAsImage(&quot;/tmp/mymap.png&quot;)<br>
<br>
If you want a server process generating maps from the (changing?) shapefile, you need a WMS (Web Mapping Server). You can use QGIS mapserver for that: <a href="http://karlinapp.ethz.ch/qgis_wms/" target="_blank">http://karlinapp.ethz.ch/qgis_wms/</a>. But even more famous ones like Minnesote Mapserver (<a href="http://mapserver.org" target="_blank">mapserver.org</a>), or Geoserver (<a href="http://geoserver.org" target="_blank">geoserver.org</a>).<br>


<br>
<br>
Regards,<br><font color="#888888">
<br>
Richard Duivenvoorde<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><div>Thanks &amp;&amp; Regards</div>Rashad<br>