[PYTHON] Draw shapes on feature layers with ArcPy

Draw points

procedure

  1. Create a point type feature class --Here, as an example, set the name to "TestPoint". --Others are left as default.
  2. Execute Python code --Point data is created in the feature class.
  3. Show feature classes as layers --Point data is drawn.

code

insertPoint.py


import arcpy

#Create a cursor for inserting data.
#1st argument: Data name to be operated. Specify the TestPoint feature class (point type) created in advance.
#Second argument: The field name in the data. Created by default in TestPoint
#There are only two fields, OBJECTID and SHAPE.
#OBJECTID is not an operation target (can't it? It shouldn't be done in the first place ...), so
#Here, specify the SHAPE field (XY coordinates).
cursor = arcpy.da.InsertCursor(
    "D:/GIS/ArcGIS_Project/GeometryTest/GeometryTest.gdb/TestPoint",
    ["SHAPE@XY"])

#XY coordinates(0, 0)Insert point data.
#Arguments: A list of field values. In the above[SHAPE@XY]I specified that, so according to it[XY coordinates]Give in the list.
cursor.insertRow([(0, 0)])

#XY coordinates(1, 1)And(2, 2)Insert points as well.
cursor.insertRow([(1, 1)])
cursor.insertRow([(2, 2)])

#Delete the cursor.
#Note: If you do not do this, the data operations up to the above will not be confirmed, so don't forget.
del cursor

screenshot

Create point type feature class

2019-11-17-15-23-47.png 2019-11-17-15-24-30.png

Run python code

2019-11-17-15-25-54.png

Show feature classes as layers

2019-11-17-15-30-28.png 2019-11-17-15-28-32.png

Recommended Posts

Draw shapes on feature layers with ArcPy
Draw Japanese with matplotlib on Ubuntu
Draw shapes with OpenCV and PIL
Embed other images on the raster with ArcPy
Make Lambda Layers with Lambda
Multiple file processing with Kivy + Matplotlib + Draw Graph on GUI