My experience with gdalpoligonize (that you can acesa also from GMT.jl as “poliginize”) is that if not used with mask images (just 0s & 1s) is that it generates LOTS of polygons.
using GeometryOps
polygonize(lookup(rast, X), lookup(rast, Y), rast)
And that will mostly work. But not its not properly handling Rasters.jl Intervals, e.g. with gdal files the lookup values are the start or the interval, not the middle.
We should add a GeometryOpsRastersExt extension to Rasters.jl to make this work correctly with just:
using GeometryOps
polygonize(rast)
I do work on both of these packages, but we haven’t gotten around to these integrations yet. Issue here:
works on a AbstractMatrix but not on my data… 477×285 Raster{Int32,2} Rasters.NoKW() extent: Extent(X = (525700.0, 621100.0), Y = (5.5461e6, 5.6031e6)) missingval: -9999 crs: EPSG:25832
i just get Any[] without an error
Hmm I’m not sure how that line can work on a non-DimensionalData.jl compatible AbstractMatrix…
It would be best to post a MWE. You need to include all coda and all data, generating rasters or downloading them in the script so we can copy, paste and it just runs without any other work.
We should with make GeoJSON handle a Vector, or make GeometryOps return a GeometryCollection or just MultiPolygon from polygonize. Its very early days for GeometryOps. It should be accurate and its insanely fast, but workflows like this are not polished yet.
Then read will get you a GeometryCollection back:
julia> GeoJSON.read("test.json")
GeometryCollection with 1 2D geometries
polygonise is probably the least polished and tested method in GeometryOps, this is a good reminder to make it better. Ideally we would allow multiple algorithms too.
See what we can do, and thanks for all the feedback.
I haven’t gotten around to adding the extension to Rasters to make it “just work” on a raster. But it mostly works if you get the lookups manually.