1

I have a table in a native SQL database (no geodatabase, dc_geobank_public.sde in the code) with cca. 300 000 records and 18 fields. Two of the field contains projected X and Y coordinates, and one field contains geometry with SQL geometry type. The spatial index is rebuilt regularly with default parameters in MS SQL Server. The projection code is EPSG:23700. Based on this data I would like to create and update a feature class in a geodatabase (dc_geobank_map.sde in the code) on a daily basis.

So far I have written the following script, and it does the job, but clicking on the table in ArcCatalog and using the "Create table... from XY data" runs 100 times faster. (The script runs for 6 hours, and the "Create table... from XY data" tool runs for 3 minutes). Here is the script:

#importing arcpy library
import arcpy

#define workspace, this is the native SQL database
arcpy.env.workspace = r"C:\scripts\dc_geobank.sde"

print "changed workspace!"

#we let the script overwrite existing feature class
arcpy.env.overwriteOutput = True

print "output overwrite set!"

#creating xy event layer from table
arcpy.MakeXYEventLayer_management("geobank.dbo.FRS_fullos","EOV_X","EOV_Y","furasxy","23700")

print "eventlayer ready!"

#change workspace, that's where the feature class should be created, and THIS is a geodatabase
arcpy.env.workspace = r"C:\scripts\dc_geobank_map.sde"

print "changed workspace!"

#convert event layer to feature class
arcpy.CopyFeatures_management("furasxy","furas")

#project the feature class to Web Mercator projection
arcpy.Project_management("geobank_map.DBO.furas"","furasprojected","3857")

Anyone knows what the "Create feature class from XY data" tool might use that's so much faster? So far I am not making use of the geometry field, but I guess it should be useful.

EDIT: For better understanding of the issue: later on I would like to make a map service and a web mapping application based on this feature class. So my question:

How to make a feature class from the table faster?

I am on the 10.2.1 ArcGIS stack.

  • Please edit the question to: explain why you aren't using the geometry column in a Query Layer, clarify how you can have "no geodatabase" and add a simple feature class to the connection, include what you meant in the deleted comment about multiple projections, and make this question ask a single question, as per GIS SE policy. – Vince Jul 3 '15 at 10:33
  • I don't use Query Layer because it is slower in rendering, than a feature class. As it can be seen from the script, it is two seperate connection. One is geodatabase, other is native sql database. The answer for the rest of your questions is in my edited queestion, too. – Benedek Simo Aug 6 '15 at 11:24
1

The solution was to use a SearchCursor and an InsertCursor to copy the data from the event layer to the feature class. This solution was found here.

It is multple times faster than the arcpy.CopyFeatures_management tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.