Hi Chaitanya,<div><br></div><div>GeoJSON does seem to be an exception, although the ogr driver can directly read the GeoJSON string, the generic virtual memory file doesn't seem to work:</div><div><br></div><div><div> inputDataStr = "{geojson_string}"; </div>
<div> gdal.FileFromMemBuffer('/vsimem/temp', inputDataStr);</div><div> inputDriver.Open('/vsimem/temp', 0);</div><div><br></div>Is that expected?</div><div><br></div><div>Thanks.</div><div><br><div class="gmail_quote">
On Thu, Jul 5, 2012 at 10:19 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 Chaitanya,<div><br></div><div>This works great, thanks a lot for the advice. Here is basic code pattern:</div><div><br></div><div><div> inputDataStr = "<input_geojson_or_gml_str>"; </div><div> gdal.FileFromMemBuffer('/vsimem/temp', inputDataStr);</div>
<div> inputDriver.Open('/vsimem/temp', 0);</div><div><br></div><div>Thanks,</div><div>Yingqi</div><div><div class="h5"><br><div class="gmail_quote">On Tue, Jul 3, 2012 at 8:18 PM, Chaitanya kumar CH <span dir="ltr"><<a href="mailto:chaitanya.ch@gmail.com" target="_blank">chaitanya.ch@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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" target="_blank">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" target="_blank">http://www.gdal.org/ogr/classOGRGeometryFactory.html</a><br>
[2]: <a href="http://www.gdal.org/ogr/classOGRGeometry.html" target="_blank">http://www.gdal.org/ogr/classOGRGeometry.html</a><br><br><div class="gmail_quote"><div><div>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>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>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></div></div>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">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><span><font color="#888888"><br></font></span></blockquote></div><span><font color="#888888"><br>
<br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>
<br><a href="tel:%2B91-9494447584" value="+919494447584" target="_blank">+91-9494447584</a><br>17.2416N 80.1426E<br>
</font></span></blockquote></div><br></div></div></div>
</blockquote></div><br></div>