1

I have taken out DEM data over a specific area and converted the raster to polygons.

Now I want to code so I get the max value and the min value of "gridcode" of every set of polygons that are connected to each other. The polygons that are disconnected are in the same layer so I need so seperate the disconnected polygons before making a for loop which test the min and max value.

Do anyone have an efficient solution?

enter image description here

My Code:

import arcpy
import os
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")

arcpy.env.workspace = 'C:\Users\daniel\Studier\Applikationsutveckling\Projekt\Gavle'

pulka_pol = r'C:\Users\daniel\Studier\Applikationsutveckling\Projekt\Gavle\Gavle_projekt.gdb\Pulka.shp'

demdata_gavle = r'C:\Users\daniel\Studier\Applikationsutveckling\Projekt\Gavle\Demdata2\Demdata.tif'

outExtractByMask = ExtractByMask(demdata_gavle, pulka_pol)

if arcpy.Exists("mask_extract.tif"): arcpy.management.Delete("mask_extract.tif")

outExtractByMask.save("mask_extract.tif")

outPolygons = r'C:\Users\daniel\Studier\Applikationsutveckling\Projekt\Gavle\dem_poly.shp' arcpy.RasterToPolygon_conversion(outExtractByMask, outPolygons, "NO_SIMPLIFY", "VALUE")

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Daniel
  • 59
  • 4
  • 1
    Zonal statistics as table does it. Why script? – FelixIP Dec 25 '21 at 00:32
  • The thing is that if i do that i will receive statistics over all polygons, i need some way of seperating the cluster of polygons that intersects and taking zonal statistics of them after i seperated them is this possible? – Daniel Dec 25 '21 at 02:20
  • Dissolve into single parts or use statistics 2 – FelixIP Dec 25 '21 at 02:33
  • https://gis.stackexchange.com/questions/371783/zonal-statistics-2-ends-up-causing-a-fatal-error-is-there-an-alternative/371790#371790 – FelixIP Dec 25 '21 at 02:35
  • Sounds like you need region group then zonal statistics as table, no converting to vector required. – user2856 Dec 25 '21 at 11:48

0 Answers0