arcpy.Append_management creates spatial index

4845
4
Jump to solution
02-12-2015 01:02 AM
Rvan_Rijen
New Contributor II

Hi,

We are using arcpy.Append_management to import shape files into existing tables in an Oracle database. For some reason Append_management automatically creates a spatial index after the append. We don't want this behaviour. How can we disable the automagical creation of a spatial index?

Thanks,

Rob

0 Kudos
1 Solution

Accepted Solutions
Rvan_Rijen
New Contributor II

Thanks Neil!

For me as an Oracle developer, the automatic creation of the spatial index is not a feature but a bug

Your reply has triggered me to look at the arcpy.env settings and initial test show that maintainSpatialIndex does the trick

arcpy.env.maintainSpatialIndex = True


It's a bit counter-intuitive, but it looks like arcpy.env.maintainSpatialIndex = True actually means: leave the spatial index status unchanged and if none exists, don't create one.

Regards,

Rob

View solution in original post

4 Replies
NeilAyres
MVP Alum

Well the creation of the spatial index is a feature of the geodb.

You can create a very long list of inputs and have them all appended together, that way the spatial index is calculated only once at the end.

If you append them invidually, each time append runs the spatial index will be recalculated, which does increase processing time.

Perhaps you can mess with the spatialGrid1, 2, 3 in the arcpy.env settings. Set them all to 0 and see what happens.

Rvan_Rijen
New Contributor II

Thanks Neil!

For me as an Oracle developer, the automatic creation of the spatial index is not a feature but a bug

Your reply has triggered me to look at the arcpy.env settings and initial test show that maintainSpatialIndex does the trick

arcpy.env.maintainSpatialIndex = True


It's a bit counter-intuitive, but it looks like arcpy.env.maintainSpatialIndex = True actually means: leave the spatial index status unchanged and if none exists, don't create one.

Regards,

Rob

NeilAyres
MVP Alum

Good to here that you have found the workaround

SandeepKuniel
New Contributor II

Ausome post Neil's,

Been struggling to find a solution to this, especially when the feature class turns to million rows, the append goes on for ever on postgre DB.

But, after this environment setting, it just takes minutes.

However, i have a question to you.

Do i need to rebuild the spatial index regularly or will the postgre DB take care of this?

I know that, i am asking a postgre DB related question, but this might be applicable for others as well.

Regards

Sandeep

0 Kudos