parsing geojson points and extract the bounding box

414 views
Skip to first unread message

Luca De Felice

unread,
Apr 21, 2016, 6:25:06 PM4/21/16
to NetTopologySuite
Hi all,
I would like to parse a geojson file, which is actually a featurecollection of points, in order to get the minimum bbox.
I successfully parse data using NetTopologySuite.IO.GeoJson obtaining FeatureCollection Object, but I don't know if there is a simple way for getting the bbox of the set of points.
Do you have any suggestion?
thank you very much in advance.
Luca

Diego Guidi

unread,
Apr 22, 2016, 1:11:26 AM4/22/16
to NetTopologySuite
try with IGeometryCollection.Envelope

Luca De Felice

unread,
Apr 22, 2016, 3:35:30 AM4/22/16
to NetTopologySuite
Thnaks Diego, but the problem is how to get IGeometryCollection from FeatureCollection Object, look at the snippet below.

                string json = getJsonString(_url);
                var reader = new NetTopologySuite.IO.GeoJsonReader();
                NetTopologySuite.Features.FeatureCollection result = reader.Read<NetTopologySuite.Features.FeatureCollection>(json);
Grazie, Luca

FObermaier

unread,
Apr 22, 2016, 4:45:21 AM4/22/16
to NetTopologySuite
You will have to iterate over the Features in the FeatureCollection and merge the Feature.Geometry.EnvelopeInternal items.

Luca De Felice

unread,
Apr 22, 2016, 11:33:07 AM4/22/16
to NetTopologySuite
Thank you very much FObermaier, as usual you got the point, but what do you mean merge? should I use the method ExpandToInclude?
like below snippet>

                GeoAPI.Geometries.Envelope bbox = new GeoAPI.Geometries.Envelope();
                foreach (var feature in result.Features)
                {
                    bbox.ExpandToInclude(feature.Geometry.EnvelopeInternal);
                }

Thanks a lot, Luca

Felix Obermaier

unread,
Apr 24, 2016, 11:14:20 PM4/24/16
to nettopol...@googlegroups.com

Yes. That is it.

 

--
You received this message because you are subscribed to the Google Groups "NetTopologySuite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nettopologysui...@googlegroups.com.
To post to this group, send email to nettopol...@googlegroups.com.
Visit this group at https://groups.google.com/group/nettopologysuite.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages