<a href="http://www.bostongis.com/PrinterFriendly.aspx?content_name=ogr_cheatsheet">http://www.bostongis.com/PrinterFriendly.aspx?content_name=ogr_cheatsheet</a><br><br>I use ogr2ogr for doing that..&nbsp; however sometimes its best to write the KML using your own structure, descriptions, and element names.
<br><br><a href="http://www.gdal.org/ogr/drv_kml.html">http://www.gdal.org/ogr/drv_kml.html</a> will describe the options that let you name the KML elements based off of a database fields data.<br><br><div><span class="gmail_quote">
On 9/14/07, <b class="gmail_sendername">Dylan Beaudette</b> &lt;<a href="mailto:dylan.beaudette@gmail.com">dylan.beaudette@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Friday 14 September 2007, John Smith wrote:<br>&gt; as_kml()?! there&#39;s another askml() in line with asgml(). why this<br>&gt; alias/name change/confusion?<br>&gt;<br>&gt; anyway how does it really work? getting a &quot;Must contain
<br>&gt; &#39;geometry_column from table_name&#39; or &#39;geom from (subselect) as foo&#39;<br>&gt; (couldnt find &#39; from &#39;)&quot;. what do i do after passing bbox=... and<br>&gt; type=kml to export script? the sql doesn&#39;t go inside .map, right? can
<br>&gt; some share a detailed use/script? not much in<br>&gt; <a href="http://postgis.refractions.net/docs/postgis.pdf">http://postgis.refractions.net/docs/postgis.pdf</a><br><br>I&#39;ll add a bit to this discussion, as I have tackled it before.
<br><br>&gt; btw super example at<br>&gt; <a href="http://casoilresource.lawr.ucdavis.edu/ka-map/htdocs/?map=casoil&amp;cps=-20125">http://casoilresource.lawr.ucdavis.edu/ka-map/htdocs/?map=casoil&amp;cps=-20125</a><br>&gt;
07.9410234897,-132997.150403761,500000&amp;layers=__base__<br><br>Thanks! Here is a shorter link to the corresponding page:<br><a href="http://casoilresource.lawr.ucdavis.edu/drupal/node/429">http://casoilresource.lawr.ucdavis.edu/drupal/node/429
</a><br><br>&gt;although i didn&#39;t<br>&gt; quite get this part:<br>&gt; 1. select geometry overlapping the bounding box defined by the current<br>&gt; viewport in AEA coordinates, using the PostGIS spatial indexing system
<br>&gt; 2. compute the intersection between the boinding box and the<br>&gt; overlapping polygons<br>&gt; 3. compute the centroids of the new geometry<br>&gt; 4. convert the polygon geometry to KML<br>&gt; 5. convert the centroid geometry to KML
<br>&gt; 6. return resulting text<br><br>This is a list of how the PHP code is functioning; some background--<br><br>I have a massive table of polygons, stored in a custom AEA projection. Google<br>Earth is not happy about massive KML files, so PostGIS is used to &#39;cut-out&#39;
<br>(intersection) a chunk. This chunk is then converted into KML, with all of<br>the extra XML styling etc. added by a PHP wrapper script. A second pass is<br>done with PostGIS to get the centroids of the polygons, which are used as a
<br>labeling mechanism. All of the KML / XML chunks are stuck into a dynamically<br>generated KML document and returned to the user.<br><br>I was able to construct this by<br>1. looking over the KML specs<br>2. looking at some example KML files
<br>3. experimentation<br><br>Further work should definitely use something other than string functions to<br>build the XML.<br><br>Another hint: be sure to send the KML header by PHP first:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;header(&quot;Pragma: public&quot;); // required
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;header(&quot;Expires: 0&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;header(&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;header(&quot;Content-Type: application/kml; charset=utf8&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;header(&#39;Content-Disposition: attachment; filename=&quot;file.kml&quot;&#39;) ;<br><br><br>check out the examples on the above link, and dissect the resulting KML file<br>for hints.<br><br>Cheers,<br>
<br>Dylan<br><br><br><br><br><br>&gt; cheers, jzs<br>&gt;<br>&gt; On 9/14/07, Jose Gomez-Dans &lt;<a href="mailto:jgomezdans@gmail.com">jgomezdans@gmail.com</a>&gt; wrote:<br>&gt; &gt; Hi Maciej,<br>&gt; &gt; I sent you an e-mail, but your spam protection system wouldn&#39;t allow
<br>&gt; &gt; the message to go through.&nbsp;&nbsp;If you have another address, I&#39;ll resend<br>&gt; &gt; it to you :)<br>&gt; &gt;<br>&gt; &gt; On 9/14/07, Maciej Skorczewski &lt;<a href="mailto:maciej.skorczewski@procad.pl">maciej.skorczewski@procad.pl
</a>&gt; wrote:<br>&gt; &gt; &gt; how sql should looks like?<br>&gt; &gt;<br>&gt; &gt; Simply (and this is already quite advanced: you can use simplify() to<br>&gt; &gt; reduce the number of points in your vector data. Ours are very
<br>&gt; &gt; detailed, and we don&#39;t want that on our KML files):<br>&gt; &gt;<br>&gt; &gt; SELECT AS_KML(SIMPLIFY(the_geom,100)) from MY_TABLE;<br>&gt; &gt;<br>&gt; &gt; &gt; Question about Python class...i am not python programer can you
<br>&gt; &gt; &gt; describe my how i can use it?<br>&gt; &gt;<br>&gt; &gt; You just write a small python program to use it. You should be able to<br>&gt; &gt; do the same with PHP.<br>&gt; &gt;<br>&gt; &gt; Cheers,<br>&gt; &gt; José
<br>&gt;<br>&gt; _______________________________________________<br>&gt; postgis-users mailing list<br>&gt; <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>&gt; <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">
http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br><br><br><br>--<br>Dylan Beaudette<br>Soils and Biogeochemistry Graduate Group<br>University of California at Davis<br>530.754.7341<br>_______________________________________________
<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users
</a><br></blockquote></div><br>