Hex grid from layer bounds issue

المشرف العام

Administrator
طاقم الإدارة
I'm trying to use the 'Hex grid from layer bounds" script to reproduce the simple "Mapping density with hexagonal grids" from the Learning GIS book. When I run the script "as is" I get the error: Data Source() invalid.

I did stumble upon a pretty good thread where there were multiple examples of how to rewrite the script but all of them gave different types of errors:For example this script:

import processinglayer = canvas.layer(0)cellsize = 1000input = processing.getobject(layer.name())centerx = (input.extent().xMinimum() + input.extent().xMaximum()) / 2centery = (input.extent().yMinimum() + input.extent().yMaximum()) / 2width = (input.extent().xMaximum() - input.extent().xMinimum())height = (input.extent().yMaximum() - input.extent().yMinimum())grid="grid.shp"processing.runandload("qgis:creategrid", cellsize, cellsize, width, height, centerx, centery, 1, input.crs().authid(), grid)*generates an error:

name 'canvas' is not defined See log for more details

I'm pretty much a newbie with QGIS and I'm going through the Learning GIS book word for word...so this one has me really stuck.

I'm using QGIS version 2.8 on a Macbook Pro.

Any help would be appreciated.



أكثر...
 
أعلى