[Gdal-dev] Simple SHP file creation with Python..API question

Aykut KOÇAK aykutkocak at superonline.com
Tue Feb 7 07:03:33 EST 2006


Thanks those were very helpfull,

I have already written below code to update single point within a point 
type shape file, but it can not update the file.

I am not well experienced on OGR API yet!.

anybody comments on it ?

Aykut


import ogr,getopt,sys

shpfile='point.shp'
location='32.862450,39.966323'
(options, arguments) = getopt.getopt(sys.argv[1:], 
"l:f:h",["location=","file=","help"])
for (switch, val) in options:
if switch in ('-h', '--help'):
sys.stderr.write("usage: updateshp [-h] [-l] [--location] [-f] [--file]\n")
raise SystemExit,0
elif switch in ('-l','--location'):
location = val
elif switch in ('-f','--file'):
shpfile = val

def main():
global shpfile
global location
map=ogr.Open(shpfile,1)
layer=map.GetLayer(0)
ftr=layer.GetFeature(0)
geo_ref=ftr.GetGeometryRef()
geo=geo_ref.GetGeometryRef(0)
loc=location.split(',')
geo.SetPoint(0,float(loc[0]),float(loc[1]),0)
map.Release()
return
main()


Mateusz Łoskot wrote:

> Aykut KOÇAK wrote:
>
>> hi gdal users,
>>
>> Could somebody suggest me any ptyhon example creating SHP files?
>>
>
> I hope tutorials below will be helpful:
>
> http://zcologia.com/news/16
> http://www.perrygeo.net/wordpress/?p=4
>
> Those tutorials are not strictly OGR HOW-TOs but you will find there 
> instructions how to create ESRI Shapefile with OGR from Python.
>
> Cheers



-- 
Aykut KOÇAK

Elektronik Mühendisi
(/Electronics Engineer/)

E-Posta
(/E-Mail/ )

aykutkocak at superonline.com




More information about the Gdal-dev mailing list