3

I have a CSV file that has 40000 records with minx, miny, maxx, maxy attributes. I want to create a bounding polygon for each record from those values. I have tried using geometry replacer in FME 2016.1 but it is not creating the geometry (with no error given). I have FME, ArcGIS 10.4.1 and Global Mapper 17.2. Any clues on how to proceed?

3 Answers 3

3

With FME you'd probably read the data as plain CSV and then use the 2DBoxReplacer transformer to convert the four different fields into a true polygon geometry.

The GeometryReplacer is more for creating geometry from an attribute containing XML, JSON, or WKT - which it doesn't sound like you have.

0
3

With ArcGIS the simplest way to do this is to use Python.

Copy the following code in the Python window of ArcCatalog or ArcMap and you should get it done (first change the input table, output feature class and field names in the cursor if necessary):

import arcpy

table = r"D:\temp\Coords.txt"
out_fc = r"D:\temp.gdb\polygons"

polygons = []

with arcpy.da.SearchCursor(table, ["minX", "minY", "maxX", "maxY"]) as cur:
    for row in cur:
        coord_list = [[row[0], row[1]], [row[0], row[3]], [row[2], row[3]], [row[2], row[1]]]
        features.append(arcpy.Polygon(arcpy.Array([arcpy.Point(x[0],x[1]) for x in coord_list])))

arcpy.CopyFeatures_management(polygons, out_fc)

This code snippet is derived from the example at the very bottom of the help page for the Polygon arcpy class.

1
  • Thanks, that works. I have gone with the FME solution only because I have FME at hand. Jul 14, 2016 at 23:03
0

You can checkout point2poly JavaScript application at geospatialearth.in site. Click link.

In this application you can browse your csv file and upload. Your browser will show the preview and you need to select geometry type as Extend_poly and two corner coordinates from you csv table column name. You can then choose what do you want to save KML or Shapefile.

Everything is processed at the client side using js2shapefile.js JavaScript.

2
  • Although helpful for points I can't seem to get to work with minx, miny, max x, max y Jul 14, 2016 at 23:05
  • This link is even helpful for rectangle, buffer and Polygon using min max coordinates. Cleck out the drop-down option. All the best. Jul 18, 2016 at 17:50

Your Answer

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

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