<br><br>
<div class="gmail_quote">2010/10/14 Susana Iraiis Delgado Rodriguez <span dir="ltr"><<a href="mailto:susana.delgado_s@utzmg.edu.mx">susana.delgado_s@utzmg.edu.mx</a>></span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>Thanks for the help Frank, but do you have any idea how to fix it? See I have to do the for cicle in order to fill alll my file with information, if some of miy shapes don't have feature, how can I fix the code so it keeps execuitng? What I need is the name of the geometry : poitn, line, polygon.</div>
<div><br><br> </div>
<div class="gmail_quote">2010/10/14 Frank Warmerdam <span dir="ltr"><<a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a>></span>
<div>
<div></div>
<div class="h5"><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>Susana Iraiis Delgado Rodriguez wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"> shapeData = ogr.Open(filepath)<br> layer = shapeData.GetLayer()<br> feature = layer.GetNextFeature()<br>
wksht.row(row).write(7, layer.GetFeatureCount())<br> #Here is the problem, when I want to get the geometry name,<br> geometry = feature.GetGeometryRef()<br> geometryType = geometry.GetGeometryName()<br> wksht.row(row).write(6, geometryType)<br>
#<br><br>wrkbk.save('shp.xls')<br> When the module gets to the geometryName part, ti throws me the error:<br>Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on<br>win32<br>Type "help", "copyright", "credits" or "license" for more information.<br>
>>> import excel_craw<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br> File "excel_craw.py", line 45, in <module><br> geometry = feature.GetGeometryRef()<br>
AttributeError: 'NoneType' object has no attribute 'GetGeometryRef'<br> >>><br></blockquote><br></div>Susana,<br><br>I don't know why the above didn't work, and running in IDLE did<br>work. But I will note that the error message is indicating that<br>
the "feature" is None, that is layer.GetNextFeature() returned None.<br><br>Best regards,<br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>I don't undestand the reason of the error, because I run the next lines in IDLE Python an this is what I got:<br> >>> import os<br> >>> from osgeo import ogr<br> >>> shapeData = ogr.Open('tapalpa_05_plani_point.shp')<br>
>>> layer = shapeData.GetLayer()<br> >>> feature = layer.GetNextFeature()<br> >>> geometry = feature.GetGeometryRef()<br> >>> geometryType = geometry.GetGeometryName()<br> >>> print geometryType<br>
POINT<br> Why is my other code wrong?<br> <br><br></div>------------------------------------------------------------------------<br><br>_______________________________________________<br>FWTools mailing list<br><a href="mailto:FWTools@lists.maptools.org" target="_blank">FWTools@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/fwtools" target="_blank">http://lists.maptools.org/mailman/listinfo/fwtools</a><br><a href="http://fwtools.maptools.org/" target="_blank">http://fwtools.maptools.org/</a><br>
</blockquote><br><br>-- <br>---------------------------------------+--------------------------------------<br>I set the clouds in motion - turn up | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>
light and sound - activate the windows | <a href="http://pobox.com/~warmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>and watch the world go round - Rush | Geospatial Programmer for Rent<br><br></blockquote>
</div></div></div><br></blockquote></div><br>