django-raster rendering raster url

69 views
Skip to first unread message

Xristos Xristoou

unread,
Jul 3, 2018, 3:43:07 PM7/3/18
to Django users

i want to add raster functionality in django using postgis database using django-raster package and this docs.

here my code :

models.py

from django.contrib.gis.db import models
class RasterWithName(models.Model):
    raster = models.RasterField()
    name = models.TextField()

add raster using console :

from django.contrib.gis.gdal import GDALRaster
from myapp.models import RasterWithName
gdal_raster = GDALRaster('C:/Users/username/Desktop/image.tif')
rast = RasterWithName(name='one', raster=gdal_raster)
rast.save()

but i am very confused with Rendering tiles and urls.

docs say :

/raster/tiles/layer_id/{z}/{x}/{y}.png where the layer_id is the primary key of a raster layer. This structure can be used directly in online mapping software such as OpenLayers or Leaflet. An example request could look like this: /raster/tiles/23/8/536/143.png, returning a tile in png format of the layer with ID pk=23 at zoom level z=8 and indexes x=536 and y=143

but indexes x,y mean some random x,y coordinate in image ?anyway i using this url http://127.0.0.1:8000/raster/tiles/1/8/536/143.png or http://127.0.0.1:8000/raster/tiles/1/8/20/40.png(origin x,y in my image) and i take a black window in my browser,any idea where i have wrong in my url rendering ?

Jason

unread,
Jul 3, 2018, 4:33:09 PM7/3/18
to Django users
No, they don't mean coordinates, they mean the actual index location in a grid.

Say you have a 100x100 grid, each (x, y) coordinate like (1, 5) represents one tile image.

Xristos Xristoou

unread,
Jul 4, 2018, 9:41:24 AM7/4/18
to Django users
hello

you mean that need height/width or some pixel inside in image ?

thank you 

Jason

unread,
Jul 4, 2018, 9:54:23 AM7/4/18
to Django users
No.  Ever see a tile floor?  each tile is one image with a filename.  you use the x y coordinates to get the path to that image

Xristos Xristoou

unread,
Jul 4, 2018, 9:57:38 AM7/4/18
to Django users


Τη Τετάρτη, 4 Ιουλίου 2018 - 4:54:23 μ.μ. UTC+3, ο χρήστης Jason έγραψε:
No.  Ever see a tile floor?  each tile is one image with a filename.  you use the x y coordinates to get the path to that image


how to find this information ?because that image converting to 3857 system? 

Xristos Xristoou

unread,
Jul 5, 2018, 1:56:40 PM7/5/18
to Django users
i need this help
Reply all
Reply to author
Forward
0 new messages