geodesign / django-raster

Django-raster allows you to create tiled map services (TMS) and raster map algebra end points for web maps. It is Python-based, and requires GeoDjango with a PostGIS backend.
BSD 3-Clause "New" or "Revised" License
96 stars 39 forks source link

how to use Raster algebra TMS endpoint #41

Closed xxqhh closed 4 years ago

xxqhh commented 4 years ago

Hi,I have new problem。 http://localhost:8000/raster/algebra/{z}/{x}/{y}.png?layers=a=78,b=0,c=1,d=2 Is this code correct? a:layerid b:band1 c:band2 d:band3 Thank you

xxqhh commented 4 years ago

I think i have new idea,It seems that I misunderstood it before. image Is that correct? Thank you

yellowcap commented 4 years ago

I guess from your code that you are trying to render RGB data (three bands). RGB rendering is documented here:

https://django-raster.readthedocs.io/en/stable/algebra.html#rgb-endpoint

The data is rendered as RGB if you specify the "keys" as r, g, and b.

If you ingested your raster as a 3-band raster, you have to reference the bands with RASTERLAYERID:BAND_INDEX. in the url. If you ingested each band separately, simply use the rasterlayer id directly.

For accessing individual bands is documented here https://django-raster.readthedocs.io/en/stable/algebra.html#using-specific-bands

In your case, if you have 3-band rasters ingested, your url would look like this:

http://localhost:8000/raster/algebra/{z}/{x}/{y}.png?layers=r=78:0,g=78:1,b=78:2

assuming red = band0, green=band1, blue=band2

If your data is already in 8bit integers (or scaled from 0 to 255) this should render just fine. Otherwise you might have to use the scale parameter as described in the docs.

If your image is too dark or has not a lot of saturation, you can also manipulate the rendering on the fly using the enhancement url parameters, see

https://django-raster.readthedocs.io/en/stable/algebra.html#image-enhancement

yellowcap commented 4 years ago

btw - @xxqhh does that mean you were able to solve the parsing problems? Please let me know if you solved the issues, so that I can make sure it does not happen to other users using conda on windows.

xxqhh commented 4 years ago

Eventually, it seems that the file will be opened and unreadable.I think it's better to develop with Linux I looked through the document and found some problems.This code doesn't seem to be executable. image At the same time, I don't understand this very well. image How to determine layer_id?

yellowcap commented 4 years ago

The url was missing a rasterlayer id indeed. Fixed here https://github.com/geodesign/django-raster/commit/0ad8a778d3ef8b2b564c4968fa9ed01160887ed4. About the code, what part does not work for your?

xxqhh commented 4 years ago

Successful. I don't know why I couldn't come out before.