Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

i have the following coordinates

minx,maxx,miny,maxy = 448262.080078, 450360.750122, 6262492.020081, 6262938.950073

i wish to create a square grid of size 1 m using python.

import math


minx,maxx,miny,maxy = 448262.080078, 450360.750122, 6262492.020081, 6262938.950073
size = 1

def set_bbox(minx, maxx, miny, maxy, distx, disty):
    nx = int(math.ceil(abs(maxx - minx)/distx))
    ny = int(math.ceil(abs(maxy - miny)/disty))
    new_maxx = minx + (nx*distx)
    new_miny = maxy - (ny*disty)
    return ((minx, new_maxx, new_miny, maxy),ny,nx)

# shift the bottom (right - down)
coord, ny, nx = set_bbox(minx,maxx,miny,maxy,size,size)
# left-up origin
origin = coord[0],coord[3]
# number of tiles
ncell = ny*nx
share|improve this question
Is this attached to any specific GIS platform or is the requirement to do this in pure python without any specified output format (eg. shapefile, textfile etc etc) – Dan Patterson Mar 11 at 21:07
Thanks @Dan, i wish to perform in pure python and the output will be in shapefile format – Gianni Mar 11 at 21:13
The ArcInfo level of license of ArcMap has the Fishnet tool but you haven't indicated how you intend to create the shapefile. – Dan Patterson Mar 11 at 21:17
Sorry i don't use commercial Software. I prefer program in pure language Java, Python, C++. – Gianni Mar 11 at 21:39

1 Answer

Use the pyshp library available here... http://code.google.com/p/pyshp/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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