ArcGIS Pro ModelBuilder - Iterating Raster to Polygon with Parse

703
2
09-17-2019 07:55 AM
MarkSzegner
New Contributor III

I was given a task to to convert some very large rasters of landuse into Polygons for some data analysis that needed data in vector. 

After looking at Pros and Cons of various scenarios I opted for splitting the raster (its about 3.2GB) into 6 tiles (Split Raster) to make processing "easier". OK, there may be a better way to do this step, but its done. I may repeat this later and split into smaller tiles.

I used modelbuilder  to iterate rasters then convert raster to polygon - some of the resulting polygon files are expected to be over 2GB (they tend to be anything from 6-12 times the size of the input raster) so I need to save files into a FGDB not .shp. I had problems understanding how to do this, eventually I read how to use Parse and this enables me to save Raster to Polygon output into a FGBD when using the Iterate Raster (each ones takes over an hour so that's why I wanted a model to do it iteratively).

It seemed to work, the model, but it always overwrote the first output with the last! Eventually I saw that the Parse tool only did its first iteration after the first Polygon to Raster iteration, when really the first thing that should happen during an iteration is Parse. BTW I did these tests on very small rasters first.

I could not work out how to fix this, as everything looked OK. By chance, as I was messing around I removed the Raster to Polygon tool from the model (when I first created the model I was not using the Parse utility so the Raster to Polygon tool was always there), then re-inserted Raster to Polygon and hey - it now worked as I expected.

So Q.1 does the order you insert a tool into the modelbuilder really matter? Or is this a bug? If I repeat the model creation by inserting the Parse tool after the Raster to Polygon, it starts overwriting first output with last again.

Q.2 is there any way of seeing the order of tools in a model and when they run in an iterator and rearranging that order to ensure the correct one runs first. I assumed given the location of Parse in the model window it would run first before anything got to the Raster to Polygon tool.

Q.3 In general, is there another way of doing all of this, it seems to work OK - the main issue I had was how to save feature classes keeping the same filename but omitting the .tif but using Parse seems to work as it gives a variable without the .tif suffix. 

I accept these are big unwieldy files, but it has been a useful exercise for me.

ArcGIS Pro 2.4, very fast CPU xenon, 14 cores, 64GB RAM , 3TB SSD.

0 Kudos
2 Replies
curtvprice
MVP Esteemed Contributor

So Q.1 does the order you insert a tool into the modelbuilder really matter?

Q.2 is there any way of seeing the order of tools in a model and when they run in an iterator and rearranging that order to ensure the correct one runs first. 

The default order of execution is dependent on the order things are added to ModelBuilder. You can control the order of execution by making the output of one tool (the one you want to run first) a precondition to the tool you want to run second. In your example, make %NoExt% a precondition to your Raster To Polygon tool.

Q.3 In general, is there another way of doing all of this, it seems to work OK - the main issue I had was how to save feature classes keeping the same filename but omitting the .tif but using Parse seems to work as it gives a variable without the .tif suffix.

I think your method works fine. The output path you specify to Raster To Polygon can include any model variables in the path name. A few of the useful built-in model variables you can use in the output pathname are:

%n% - the iteration (0,1,2,3)

%workspace% - the current environment workspace

%NoExt% - a model element generated by the iterator (you can use any of them).

Hope you find this information helpful!

0 Kudos
MarkSzegner
New Contributor III

Thanks, yes - I never really understood how the precondition option worked in practice, so at least I know how I can use it and I'll give it a go now I have something to test it on.

Very useful Curtis, cheers.

0 Kudos