SR = arcpy.SpatialReference(4283)
ptGeoms.append(arcpy.PointGeometry(pt4, SR)) .... array = arcpy.Array([pt1,pt2,pt3,pt4,pt1]) polygon = arcpy.Polygon(array, SR) featureList.append(polygon)
import arcpy arcpy.env.overwriteOutput = True infile = r'C:\Project\_Forums\CSV2Polygon\csv\Metadata_RP.csv' outshp_gcs = r'C:\Project\_Forums\CSV2Polygon\shp\poly_gcs.shp' outshp_pcs = r'C:\Project\_Forums\CSV2Polygon\shp\poly_pcs.shp' sr_in = arcpy.SpatialReference(4283) # GCS_GDA_1994 sr_out = arcpy.SpatialReference(28355) # GDA_1994_MGA_Zone_55 lstPolsGCS = [] lstPolsPCS = [] with arcpy.da.SearchCursor(infile, ["o_minx","o_miny","o_maxx","o_maxy"]) as curs: for row in curs: xvalues = [row[0], row[2]] yvalues = [row[1], row[3]] print "{0}, {1}, {2}, {3}".format(row[0], row[1], row[2], row[3]) pnt1 = arcpy.Point(min(xvalues),min(yvalues)) pnt2 = arcpy.Point(min(xvalues),max(yvalues)) pnt3 = arcpy.Point(max(xvalues),max(yvalues)) pnt4 = arcpy.Point(max(xvalues),min(yvalues)) polygon_gcs = arcpy.Polygon(arcpy.Array([pnt1, pnt2, pnt3, pnt4, pnt1]), sr_in) lstPolsGCS.append(polygon_gcs) polygon_pcs = polygon_gcs.projectAs(sr_out) lstPolsPCS.append(polygon_pcs) arcpy.CopyFeatures_management(lstPolsGCS, outshp_gcs) arcpy.CopyFeatures_management(lstPolsPCS, outshp_pcs)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.