Yingqi,<br><br>Though the GeoJSON driver allows for reading the data directly, it is more like an exception. For consistent behavior between formats, you need to read the data from a data source like a file or url.<br><br>
You can create a temporary in-memory file of your data using the method<br><pre>gdal.FileFromMemBuffer()</pre>Example at <a href="http://www.gdal.org/ogr/drv_georss.html">http://www.gdal.org/ogr/drv_georss.html</a><br><br>
There are also a few methods to import/export just the geometries. You can import GML and WKT [1] and export to GML, KML and JSON[2].<br><br>[1]: <a href="http://www.gdal.org/ogr/classOGRGeometryFactory.html">http://www.gdal.org/ogr/classOGRGeometryFactory.html</a><br>
[2]: <a href="http://www.gdal.org/ogr/classOGRGeometry.html">http://www.gdal.org/ogr/classOGRGeometry.html</a><br><br><div class="gmail_quote">On Wed, Jul 4, 2012 at 3:34 AM, Yingqi Tang <span dir="ltr"><<a href="mailto:anakintang@gmail.com" target="_blank">anakintang@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br><br>I am using OGR/GDAL to read GML/GeoRSS/GeoJSON from either local file or url, the sample code is like below<br>
...<br>inputDriver = ogr.GetDriverByName(inputDriverType)<br>inputDataSource = inputDriver.Open(inputDataPath, 0);<br>
...<br><br>It seems that I can pass in the GeoJSON string directly like:<br><br>inputDataSource = inputDriver.Open("<br>{'type':'FeatureCollection','features':[{'type':'Feature','id':'OpenLayers.Feature.Vector_3449','properties':{},'geometry':{'type':'Polygon','coordinates':[[[-109.3449,<a href="tel:63.6328125" value="+34636328125" target="_blank">63.6328125</a>],[-112.5,35.5078125],[-85.078125,34.8046875],[-68.90625,39.7265625],[-68.203125,<a href="tel:67.1484375" value="+34671484375" target="_blank">67.1484375</a>],[-109.6875,<a href="tel:63.6328125" value="+34636328125" target="_blank">63.6328125</a>]]]},'crs':{'type':'OGC','properties':{'urn':'urn:ogc:def:crs:OGC:1.3:CRS84'}}},{'type':'Feature','id':'OpenLayers.Feature.Vector_07050618','properties':{},'geometry':{'type':'Polygon','coordinates':[[[-40.78125,<a href="tel:65.0390625" value="+34650390625" target="_blank">65.0390625</a>],[-40.078125,34.8046875],[-12.3449,25.6640625],[21.09375,17.2265625],[22.5,58.0078125],[-40.78125,<a href="tel:65.0390625" value="+34650390625" target="_blank">65.0390625</a>]]]},'crs':{'type':'OGC','properties':{'urn':'urn:ogc:def:crs:OGC:1.3:CRS84'}}}]}", 0);<br>

<br>But it doesn't seem to work with GML or GeoRSS, did I miss anything? So basically how can I read GML/GeoRSS directly from an XML string?<br><br>Thanks<br>
<br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>
<br>+91-9494447584<br>17.2416N 80.1426E<br>