Git Product home page Git Product logo

rio-tiler-mvt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rio-tiler-mvt's Issues

potential use

@vincentsarago,

I'd like to know if it would be possible to use rio-tiler-mvt to extract individual pixels from a geotiff/numpy array and serve them further as MVT points.

I have a high res (30) raster dataset and would be curios if this could work .

thanks in advance

Vectorize shapes (instead of pixel)

Just wanted to see if it was possible. Answer: Not really but at least it was fun.

from rasterio._features import _shapes
from rasterio.rio.helpers import coords
from rasterio.transform import IDENTITY


cpdef rgb_to_hex(rgba):
    return '#{:02x}{:02x}{:02x}'.format(*rgba)


cpdef bytes shapes_encoder(
    data,
    mask,
    str layer_name = "layer",
    colormap = {},
):
    cdef float x, y
    cdef tuple rgba

    mvt = Tile()
    mvt_layer = Layer(mvt, layer_name.encode())

    for (p, v) in _shapes(data, mask, connectivity=4, transform=IDENTITY):
        feature = Polygon(mvt_layer)
        xs, ys = zip(*coords(p))
        feature.add_ring(len(xs))
        for (x, y) in zip(xs, ys):
            feature.set_point(int(x), int(y))

        if colormap:
            rgba = colormap.get(v, (0, 0, 0, 0))
            feature.add_property("rgba".encode(), rgb_to_hex(rgba).encode())
        else:
            feature.add_property("value".encode(), str(v).encode())
        feature.commit()

    return mvt.serialize()

problem:

  • polygon returned by rasterio.features._shapes are quite complex and do need better handling (interior ring, multi polygon)
  • Polygon are interesting the tile bounds and should not be polygon but LineString ๐Ÿคทโ€โ™‚๏ธ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.