4

I am currently struggling to convert x,y coordinates into individual polygons. Feature polygon and points to line is not what I am trying to do. I have sampled vegetative plots on the landscape and have recorded the X,y coordinate for the bottom left corner of the sampling polygon. I have then taken the bearings from the baseline and first transect to orientate the polygon and I have the length measurements for the baseline and transects of the polygon. I have all the information to produce and orientate a polygon from each GPS coordinate, but can not seem to find a function in arcGIS to accomplish this task. Obviously I could create feature polygons for each x,y coordinate and define each length and angle, but I have a several hundred x,y coordinates to convert to polygons. I have added a table of the information I want to use, and a photo to visually depict what I want to do.

site_characteristics_tablesite_diagram

3
  • 1
    This can be done using Python. Take a look at the examples at the bottom of: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-classes/…
    – Bera
    Commented Feb 3, 2018 at 18:58
  • Project corners, add xy. Compute 2 more pairs of xy. Merge 3 points datasets and dissolve to multipoint using wp. Use minimum bounding geometry. Note some of your records aren't rectangles, fix it first.
    – FelixIP
    Commented Feb 3, 2018 at 19:14
  • Could you add the table as text?
    – Bera
    Commented Feb 5, 2018 at 7:29

1 Answer 1

3

This can be done using Bearing Distance to Line and Add Geometry Attributes. First the four sides are created and then turned into a polygon by Minimum Bounding Geometry rectangle.

Alot of code, but seems to work.

import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.qualifiedFieldNames = False
arcpy.env.workspace = r'C:\geodatabase.gdb' #Change

intable = r'Plots' #Your table imported to the workspace
outfc = r'Plotfields'

input_spatial_reference = arcpy.SpatialReference(4326)
output_spatial_reference = arcpy.SpatialReference(32616) #Change if you want

arcpy.CreateFeatureclass_management(out_path=arcpy.env.workspace, out_name=outfc, geometry_type='POLYGON', spatial_reference=output_spatial_reference)

arcpy.MakeXYEventLayer_management(table=intable, in_x_field='GPSLONG', in_y_field='GPSLAT', 
                                  out_layer='xylyr', 
                                  spatial_reference=input_spatial_reference)

arcpy.Project_management(in_dataset='xylyr', out_dataset='projected', 
                        out_coor_system=output_spatial_reference, 
                        in_coor_system=input_spatial_reference)

arcpy.AddGeometryAttributes_management(Input_Features='project', 
                                       Geometry_Properties='POINT_X_Y_Z_M')

with arcpy.da.SearchCursor(intable, ['WP']) as cursor:
    for row in cursor:
        arcpy.MakeTableView_management(in_table='project', out_view='project_view', 
                                       where_clause="""{0} = {1}""".format(
                                           arcpy.AddFieldDelimiters(datasource='project', field='WP'),row[0]))
        #Create first line
        arcpy.BearingDistanceToLine_management(in_table='project_view', out_featureclass='line1', x_field='POINT_X', y_field='POINT_Y',
                                               distance_field='Transect_width', distance_units='METERS',
                                               bearing_field='Transect', id_field='WP', spatial_reference=output_spatial_reference)
        #  add end coordinates
        arcpy.AddGeometryAttributes_management(Input_Features='line1', 
                                               Geometry_Properties='LINE_START_MID_END', 
                                               Length_Unit='METERS', 
                                               Coordinate_System=output_spatial_reference)
        #Create second line
        arcpy.BearingDistanceToLine_management(in_table='project_view', out_featureclass='line2', x_field='POINT_X', y_field='POINT_Y',
                                               distance_field='Baseline_length', distance_units='METERS', 
                                               bearing_field='Baseline', id_field='WP', spatial_reference=output_spatial_reference)
        #  add end coordinates
        arcpy.AddGeometryAttributes_management(Input_Features='line2', 
                                               Geometry_Properties='LINE_START_MID_END', 
                                               Length_Unit='METERS', 
                                               Coordinate_System=output_spatial_reference)

        #Create third line, starting from end of line1
        arcpy.MakeFeatureLayer_management(in_features='line1', out_layer='line1_lyr')

        arcpy.AddJoin_management(in_layer_or_view='line1_lyr', in_field='WP', 
                                join_table='project_view', 
                                join_field='WP')
        arcpy.CopyFeatures_management(in_features='line1_lyr', out_feature_class='line1b')
        arcpy.BearingDistanceToLine_management(in_table='line1b', 
                                              out_featureclass='line3', 
                                              x_field='END_X', 
                                              y_field='END_Y', 
                                              distance_field='Baseline_length', 
                                              distance_units='METERS', 
                                              bearing_field='Baseline', 
                                              spatial_reference=output_spatial_reference)
        #Create fourth line, starting from end of line2
        arcpy.MakeFeatureLayer_management(in_features='line2', out_layer='line2_lyr')
        arcpy.AddJoin_management(in_layer_or_view='line2_lyr', in_field='WP', 
                                 join_table='project_view', 
                                 join_field='WP')
        arcpy.CopyFeatures_management(in_features='line2_lyr', out_feature_class='line2b')
        arcpy.BearingDistanceToLine_management(in_table='line2b', 
                                               out_featureclass='line4', 
                                               x_field='END_X', 
                                               y_field='END_Y', 
                                               distance_field='Transect_width', 
                                               distance_units='METERS', 
                                               bearing_field='Transect', 
                                               spatial_reference=output_spatial_reference)

        arcpy.Merge_management(inputs=['line1','line2','line3','line4'], output='lines')
        arcpy.Dissolve_management(in_features='lines', out_feature_class='lines_diss', 
                                 multi_part=True)
        arcpy.MinimumBoundingGeometry_management(in_features='lines_diss', 
                                                out_feature_class='rectangle', 
                                                geometry_type='RECTANGLE_BY_AREA')
        arcpy.Append_management(inputs='rectangle', target=outfc, schema_type='NO_TEST')

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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