Skip to main content
deleted 31 characters in body; edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

def run():

    Cellsize = 10
    layerPath = "path\to\shapefile"
    extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

    centerx = (extent.xMinimum() + extent.xMaximum()) / 2
    centery = (extent.yMinimum() + extent.yMaximum()) / 2
    width = extent.xMaximum() - extent.xMinimum()
    height = extent.yMaximum() - extent.yMinimum()

    outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
    outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

try:
    run()
except Exception:
    pass

Any help is always welcome!

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

def run():

    Cellsize = 10
    layerPath = "path\to\shapefile"
    extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

    centerx = (extent.xMinimum() + extent.xMaximum()) / 2
    centery = (extent.yMinimum() + extent.yMaximum()) / 2
    width = extent.xMaximum() - extent.xMinimum()
    height = extent.yMaximum() - extent.yMinimum()

    outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
    outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

try:
    run()
except Exception:
    pass

Any help is always welcome!

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

def run():

    Cellsize = 10
    layerPath = "path\to\shapefile"
    extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

    centerx = (extent.xMinimum() + extent.xMaximum()) / 2
    centery = (extent.yMinimum() + extent.yMaximum()) / 2
    width = extent.xMaximum() - extent.xMinimum()
    height = extent.yMaximum() - extent.yMinimum()

    outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
    outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

try:
    run()
except Exception:
    pass
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problemread this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

def run():

    Cellsize = 10
    layerPath = "path\to\shapefile"
    extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

    centerx = (extent.xMinimum() + extent.xMaximum()) / 2
    centery = (extent.yMinimum() + extent.yMaximum()) / 2
    width = extent.xMaximum() - extent.xMinimum()
    height = extent.yMaximum() - extent.yMinimum()

    outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
    outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

try:
    run()
except Exception:
    pass

Any help is always welcome!

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

def run():

    Cellsize = 10
    layerPath = "path\to\shapefile"
    extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

    centerx = (extent.xMinimum() + extent.xMaximum()) / 2
    centery = (extent.yMinimum() + extent.yMaximum()) / 2
    width = extent.xMaximum() - extent.xMinimum()
    height = extent.yMaximum() - extent.yMinimum()

    outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
    outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

try:
    run()
except Exception:
    pass

Any help is always welcome!

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

def run():

    Cellsize = 10
    layerPath = "path\to\shapefile"
    extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

    centerx = (extent.xMinimum() + extent.xMaximum()) / 2
    centery = (extent.yMinimum() + extent.yMaximum()) / 2
    width = extent.xMaximum() - extent.xMinimum()
    height = extent.yMaximum() - extent.yMinimum()

    outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
    outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

try:
    run()
except Exception:
    pass

Any help is always welcome!

Added modified code but still same result
Source Link
Joseph
  • 76.3k
  • 7
  • 172
  • 286

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

def run():

    Cellsize = 10
    layerPath = "path\to\shapefile"
    extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

    centerx = (extent.xMinimum() + extent.xMaximum()) / 2
    centery = (extent.yMinimum() + extent.yMaximum()) / 2
    width = extent.xMaximum() - extent.xMinimum()
    height = extent.yMaximum() - extent.yMinimum()

    outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
 
    outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

try:
    run()
except Exception:
    pass

Any help is always welcome!

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

Cellsize = 10
layerPath = "path\to\shapefile"
extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

centerx = (extent.xMinimum() + extent.xMaximum()) / 2
centery = (extent.yMinimum() + extent.yMaximum()) / 2
width = extent.xMaximum() - extent.xMinimum()
height = extent.yMaximum() - extent.yMinimum()

outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
 
outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

Any help is always welcome!

I am running a standalone script for QGIS which creates a high resolution grid and clips shapefiles onto it. Works perfect if the cell width and height have a high values (in my case, >200m for both). Anything lower than this and I suddenly get the following error:

ERROR 1: Attempt to write non-polygon (POINT) geometry to POLYGON type shapefile.

I have read this post with a similar problem, and as mentioned in the answer, the results I obtain are correct so I am not worried about that.

Is there a method to remove this error message(s) from appearing? It looks incredibly messy:

Messy messages

I've also included a stripped-down snippet of code I use:

def run():

    Cellsize = 10
    layerPath = "path\to\shapefile"
    extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()

    centerx = (extent.xMinimum() + extent.xMaximum()) / 2
    centery = (extent.yMinimum() + extent.yMaximum()) / 2
    width = extent.xMaximum() - extent.xMinimum()
    height = extent.yMaximum() - extent.yMinimum()

    outputs_0=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', None)
    outputs_1=general.runalg("qgis:clip", outputs_0['SAVENAME'], "path\to\shapefile", "create\path\for\result")

try:
    run()
except Exception:
    pass

Any help is always welcome!

Source Link
Joseph
  • 76.3k
  • 7
  • 172
  • 286
Loading