[gdal-dev] Boundary issues
Jukka Rahkonen
jukka.rahkonen at mmmtike.fi
Mon Apr 28 09:33:42 PDT 2014
Tan Hao Feng <htan <at> hsr.ch> writes:
> Dear GDAL developers,
>
> I'm trying to display the boundary out from QGIS from the following steps.
>
> Add Vector Layer.
> Select Protocol and
> insert the URL with Type as GeoJSON and select Open.
>
>
>
> The URL
is http://tools.wmflabs.org/wiwosm/osmjson/getGeoJSON.php?lang=en&article=Singapore which
> has both type "Points" and "Polygon".
>
> Is there any way to read the Polygon file only?
>
> Thanks!
>
> Hao Feng.
Hi,
That GeoJSON does not contain point and polygon types, it contains only one
type and that is GeometryCollection as you can test with
>ogrinfo -ro
/vsicurl_streaming/"http://tools.wmflabs.org/wiwosm/osmjson/getGeoJSON.php?lang=en&article=Singapore"
INFO: Open of
`/vsicurl_streaming/http://tools.wmflabs.org/wiwosm/osmjson/getGeoJSON.php?lang=en&article=Singapore'
using driver `GeoJSON' successful.
1: OGRGeoJSON (Geometry Collection)
What you can do is to write geojson into a Spatialite-db by exploding the
collections
>ogr2ogr -f SQLite -dsco spatialite=yes -explodecollections test.sqlite
/vsicurl_streaming/"http://tools.wmflabs.org/wiwosm/osmjson/getGeoJ
SON.php?lang=en&article=Singapore"
Finally you can read from Spatialite only geometries which are of type
"polygon"
>ogrinfo test.sqlite -sql "select * from ogrgeojson where
geometrytype(geometry)='POLYGON'"
Programmers for sure know some more sophisticated ways to achieve the same
result. This is an end-user solution.
-Jukka Rahkonen-
More information about the gdal-dev
mailing list