asgfantastic.blogg.se

Convert layer to shapefile arcgis modelbuilder
Convert layer to shapefile arcgis modelbuilder




convert layer to shapefile arcgis modelbuilder

Newrow = + rowĬursor.insertRow(newrow) # Insert point in FC for each row in CSV.Īnd example of a CSV that can be read is: Lat,Lon,FirstName,LastName,Tone,Magnitudeġ00,000 CSV records took about 3-5 seconds for me to run. Xcoord = row # Make sure 'Lon' is in the 2nd column. Ycoord = row # Make sure 'Lat' is in the 1st column. Default is TEXT field.Īrcpy.AddField_management(outfc, header, "TEXT")Ĭursor = arcpy.da.InsertCursor(outfc, + headers) # Create InsertCursor. Headers = reader.next() # Read the first line as the header names.įor header in headers: # Add fields for remaining columns if needed.

convert layer to shapefile arcgis modelbuilder

If not arcpy.Exists(outfc): # Create the output feature class if needed.Īrcpy.CreateFeatureclass_management(os.path.dirname(outfc), os.path.basename(outfc), "POINT", None, None, None, spatialref)Ĭsv.register_dialect("xls", delimiter=",", lineterminator="\n") # Register the dialect for native CSV syntax in Microsoft Excel. Spatialref = arcpy.SpatialReference(4326) # Create the spatial reference object as WGS84. Outfc = r"C:\Users\MyName\Desktop\My Docs\Sample Data\SampleGDB.gdb\SampleFC" # Change this to the path of your output FC. Incsv = r"C:\Users\MyName\Desktop\My Docs\Sample Data\SampleCSV.csv" # Change this to the path of your CSV file. Make sure 'Lat' and 'Lon' fields are the 1st and 2nd column in the CSV respectively. You can tweak the coordinate system in the code to something other than WGS84, tweak the field types, etc. A number of different source files are supported from any platform, such as shapefiles, CAD files, and Excel files. The script assumes the Latitude field is the 1st column and Longitude field is the 2nd column. Overview ModelBuilder is a tool available in Bentley OpenFlows products (at no extra cost) that allows you to create and update a model from a source file. Reading a CSV and populating a feature class with its values can be easy. Here's an example of technique I mentioned in the my comment to your question.






Convert layer to shapefile arcgis modelbuilder