Can we plot rectangle using minimum and maximum latitude and longitude in arcmap 10.2?

Here is a sample of the data i need to plot directly using latitude and longitude in polygon shapefile.

Here is a sample of the data i need to plot directly using latitude and longitude in polygon shapefile.

1 Answer 1


If you had the coords in an excel file and each row was lat_min,lat_max,long_min,long_max you could do something like the following using Python. Given that this is a simple example.

# -*- coding: utf-8 -*-
import os, re, xlrd
import arcpy
from arcpy import env

def dms_dd(dms_string):
    #parses a dms string in the following format 84°60'20" and return a decimal degree float number
    degrees,minutes,seconds,extra = re.split(r"[°'\"]+", dms_string)    
    decimal = 0.0
    if (int(degrees) >= 0):
        decimal = int(degrees) + float(minutes)/60 + float(seconds)/3600
        decimal = int(degrees) - float(minutes)/60 - float(seconds)/3600
    return decimal

def parseXLS_Data(xls_file):
    xl_workbook = xlrd.open_workbook(xls_file)
    sheet = xl_workbook.sheet_by_index(0)
    nrows = sheet.nrows
    ncols = sheet.ncols
    all_coords = []
    for row in range(nrows):
        if row == 0:
            x_min = dms_dd(sheet.row(row)[0].value)
            x_max = dms_dd(sheet.row(row)[1].value)
            y_min = dms_dd(sheet.row(row)[2].value)
            y_max = dms_dd(sheet.row(row)[3].value)
            coords =  [[x_min,y_min],[x_max,y_min],[x_max,y_max],[x_min,y_max]]
    return all_coords

def makepoly(coord_list, shp_file, SR=None):
    features = []
    #Convert a Python list of coordinates to an ArcPy polygon feature
    for polygon in coord_list:
        poly = arcpy.Array()
        for vertex in polygon:
            point = arcpy.Point(vertex[0],vertex[1])
        polygon = arcpy.Polygon(poly,SR)
    arcpy.CopyFeatures_management(features, shp_file)

file_xls = "path\to\coords\file.xls"
shp_file = r"path\to\polygon.shp"
polygons = parseXLS_Data(file_xls)
SR = arcpy.SpatialReference(4326)
p = makepoly(polygons, shp_file, SR=SR)

The excel file looks like this:

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.