Giter Club home page Giter Club logo

leaflet.tilelayer.gloperations's Introduction

npm version Build Status Total alerts Language grade: JavaScript Known Vulnerabilities

Leaflet.TileLayer.GLOperations

Custom Leaflet TileLayer using WebGL to do operations on and colorize floating-point pixels

Resources

Features

  • GPU rendering
  • A simple declarative API
  • A small configuration language for describing how to colorize pixels
    • Interpolated color scale
    • Sentinel values with optional labels
  • Raw float pixel value(s) provided to mouse event handlers
  • Hillshading
  • Contours
  • Animated per-pixel transitions when changing URL and/or colormaps
  • Load multiple tile layers, do operations on them and return result layer:
    • Difference between two tile layers
    • Analysis of multiple tile layers (supports 1-6 layers currently). Filter values and use a multiplier for each layer.
    • Return pixel values for both input and result layers

leaflet.tilelayer.gloperations's People

Contributors

dependabot[bot] avatar snyk-bot avatar thor85 avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar

leaflet.tilelayer.gloperations's Issues

Reduce texture atlas size

The texture atlas used is currently quite large as it is also used to cache tiles for advanced hillshading. Find a better way to cache the tiles and the texture size can be reduced.

Shadows can stretch more than one tile away

Currently using the 8 adjacent tiles to calculate advanced hillshading (3x3 grid). The shadows could stretch more than a tile away which would create artifacts. Ways to address this:

  • Add option for using larger (5x5) grid to calculate hillshading. Advanced hillshading is already a heavy operation and this would make it much heavier.
  • Raise the light source so the shadows do not stretch that far

New updateOptions during a transition

Can get some weird artifacts if a new updateOptions is sent during a transition. Wait for transition to finish or abort before using new options?

Get maximum and minimum values within current view

Hi there,

I've got your library going on the https://hirdsexplorer.nz/ website, and it's worked quite well so far.

I'd like to be able to update the colormap after every scroll event, so that it spans from the lowest to the highest values that are currently visible, to allow the user to see the spatial variation in that particular area. This is a common feature in GIS software packages. At the moment I use a global minimum and maximum on each colormap, and the maximum is dictated by the mountains.

Is this a feature that you would be willing to have in your library?

I would be willing to help in some way, but I'm not sure how. I've had a look in src/shaders/index.ts to see how pixel values are calculated, but it seems to me the challenge will be in working out which parts of each tile is visible at any one time. Do you have any ideas on how it could be done?

Thanks, Cameron

Support for GeoTIFF

Hi,

Thanks for this excellent plugin.

I have a single-band GeoTIFF file for elevation data. Would it be possible to fetch the file locally and get it to work with your module?
Please excuse my inexperience in this but I can't figure it out myself or if it is already possible with tileFormat = dem .

My thinking is to have the option for arraybuffer instead of url and/or tileFormat = tiff then modify the code for _fetchTileData to handle either arraybuffer directly or process through geotiff.js library like below.

              fetch("file.tif")
              .then(function (response) {
                return response.arrayBuffer();
              })
              .then(function (arrayBuffer) {
  		return GeoTIFF.fromArrayBuffer(arrayBuffer);
              })
              .then(function (tiff) {
                	return tiff.getImage();
              })
              .then(function (image) {
                	const width = image.getWidth();
                	const height = image.getHeight();
                	const extent = image.getBoundingBox();
                	const raster = image.readRasters();
                	const rgbImage = image.readRGB();
              })

Sorry about the code but I'm just listing the different values to get from geotiff.js.

Also, I found this code in here that can handle tiff files with an example file if it can be of help.

Float32 tile creation

Hi there,

Thanks for your module--I'm having a go at using in a project at the moment.

Your wiki page on tiles has a comment about Float32 tiles that says "Given access to the binary pixel data, producing these tiles is trivial. We just take a buffer full of 32-bit floats and hand that over to a PNG encoder, which assumes it's getting RGBA pixels." It may be trivial if you know how, but I don't and I'm definitely struggling!

I have a geotiff file of float32 data. I've written a Python script to convert this to 4 channels of integers, and then use gdal2tiles to convert it to tiles. The problem is that the data ends up all corrupted: instead of being read as values between 75 and 950 it's being read as -2.318841646091599e+38 and similar. I'm sure it's the Python script that's the problem. Can you give me some guidance on where I might be going wrong? And with respect to your package, it would be great if you could improve your documentation to explain to new users how to do that conversion process (eg with some sample code). I'm sure I'm not the only one who would find this process difficult.

If it helps to know, I'm using macOS.

Python (3.8):

import numpy as np
import rasterio

# Convert tiff with 1 channel of 32-bit floats to a file with 4 channels of
# 8-bit integers
with rasterio.open('example_input_file.tif') as src:
    floats = src.read()
    floats[floats==src.nodata]=0 # replace 'nodata' value with zero, as all
        # data values will be greater than zero
    print("Max",floats.max())
    print("Min",np.min(floats[np.nonzero(floats)]))

    treated_as_ints = np.zeros((4, floats.shape[1], floats.shape[2]))
    for channel in floats:
        for i, row in enumerate(channel):
            for j, cell in enumerate(row):
                a,b,c,d = np.frombuffer(cell, dtype=np.uint8)
                treated_as_ints[0][i][j] = a
                treated_as_ints[1][i][j] = b
                treated_as_ints[2][i][j] = c
                treated_as_ints[3][i][j] = d

    # Write to a new 4-channel 8-bit file.
    profile = src.profile
    profile.update(dtype=rasterio.uint8, count=4, compress='lzw', nodata=0)
    with rasterio.open('example_output_file.tif', 'w', **profile) as dst:
        dst.write(treated_as_ints.astype(rasterio.uint8))

gdal2tiles script:

gdal2tiles.py --xyz -w 'leaflet' -z '5' -s 'EPSG:27200' 'example_output_file.tif' tiles

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.