convert raster to polygon (model builder - iterate)

2559
11
12-20-2017 10:08 AM
rokcedilnik
New Contributor

I'm trying to convert multiple rasters to polygon and then vertices of those polygons convert to point and finally add XY coordinates. So my main tools for this process are:
- raster calculator (multiply raster with 0 to get just one band)
- raster to polygon
- feature vertices to points
- add xy coordinates

I'm trying to do this in model builder. If I use raster to polygon directly (without raster calculator), I get error that shp is bigger than 2GB. So far I manage to apply raster calculator which stores result in folder "raster_calculator". When I add raster to polygon I get error "ERROR 010157: Unable to open feature class..." (see picture "error.png").
I tried to use Calculate Value and Parse Path but I didn't succeed. Most likely because I don't know how to used them properly.

Can anyone please help me or give me an advice how to solve this in model builder.

P.S.: I know that in python this could be easier but I would like to do this in model builder because i don't understand python.

0 Kudos
11 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Firstly, I would try to produce a featureclass in a geodatabase rather than the shapefile, which is causing some problems, because you have a file with a *.tif.shp file extension which will confuse the best of software most of the time.  The 2 Gb file size limit for shapefiles is fixed and a geodatabase featureclass is your only way around that... easily.

0 Kudos
rokcedilnik
New Contributor

Thanks for quick reply. I'm trying to do what you said, but I'm not successful. Did you mean that instead of raster calculator tool I directly use raster to polygon and for output set gdb? If I do that i get an error (look picture). Can you attach a sample how should it look like in a model builder?

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

the first error in your earlier thread was because the filename contained shp and tif together.  The second is due to the fact that you didn't specify a field to do the conversion... albeit, it is optional, but some things are less optional than others... for instance, I don't see anywhere that you have checked to ensure that your rasters are integer rasters, since only they can be converted to vector form.  Floating point rasters, cannot ... they lack a table, hence, no fields.

0 Kudos
rokcedilnik
New Contributor

my first error is still present. Even if I choose output in raster to polygon tool to be gdb file, I still have shp and tif together. How can I produce a featureclass in model builder from raster?

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Your model has no parameters Creating Model Parameters ... it's all in the 'P' That parameter, the output filename, will take care of that since the model will enable you to specify a filename.  currently your filename is extremely long and convoluted ...

( d:\Rok_Cedilnik\01_ArcMap\13_izracun_oglisc_raster\test.gdb\rtp_DOF_KRANJ_A1.tif.shp )

and ends with a ....tif.shp file extension and is located in folders that begin with numbers.. effectively breaking several naming convention rules.

As for the 2 Gb file limit... that is a shapefile limit, you need to use a featureclass in a file geodatabase. 

At this point, I will let others that have been silently following the thread weigh in, I suspect that many of the issues you are facing are covered in the Modelbuilder Tutorials... so I would direct you to those since they do cover the basics.

0 Kudos
rokcedilnik
New Contributor

Ok, now I manage to do "raster calculator" and "raster to polygon" successfuly. When I create raster to polygon it gets extension "tif.shp". If I use "feature vertices to point" I get an error because of extension "tif.shp". I would like to delete extension or in the proces of "feature vertices to point" use just the name (without the extension) but I don't know how. Probably I need to use parse path and calculate value  combination but I don't know how. This is my current model and my setting and the error 

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

somename.tif.shp.replace(".tif.shp", "whatever")

0 Kudos
rokcedilnik
New Contributor

I did what you told but still get an error. Can you be more specific please. What am I doing wrong?

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

is DOF_KRANJ_A3 a shapefile? or an image.

And if it is a shapefile, you need to get its name ... ie DOF_KRANJ_A3.shp and replace the *.shp with .tif if you need to provide it with an image name ie DOF_KRANJ_A3.tif

if it is an image DOF_KRANJ_A3.tif and you need to make a shapefile you need to replace the name with .shp.

In any event, I don't know what DOF_KRANJ_A3 is since your model has no parameters and your error message and the error dialog is the exact same

0 Kudos