Skip to content

Using polygonize function on a raster doesn't keep the original raster coordinates #199

@eco-ben

Description

@eco-ben

When I use GeometryOps.polygonize() on a raster the resulting polygons do not have the same coordinates as the input raster although the same CRS is attached to the resulting polygon. This is an example with lon/lat to show effect.

using GLMakie, ArchGDAL
using Rasters, GeometryOps, GeoFormatTypes, GeoInterface

lon, lat = X(120:1:150), Y(-40:-1:-60) # Example used for clear difference from polygonize() output
ras = Raster(rand(lon, lat); crs=GeoFormatTypes.EPSG(4326))
plot(ras)

plot(ras .< 0.3)
polygons = GeometryOps.polygonize(x-> x.<0.3, ras[:, end:-1:1]) # Flip reverseordered Y 
poly(polygons)
GeoInterface.coordinates(polygons)

plot(ras .< 0.3) output:
image

poly(polygons) output:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions