[gdal-dev] Re: Multipart to singlepart

2010-12-09 Thread Jukka Rahkonen
iomeneandrei aborruso at tin.it writes: Hi all, is there in OGR a command that I can use to convert multipart polygons in singleparts? If it does not matter to use some other tool than OGR, OpenJUMP can explode multifeatures and geometry collections. I made a little test and it correctly

Re: [gdal-dev] Re: Multipart to singlepart

2010-12-09 Thread iomeneandrei
Hi Jukka, thank you for your time and for your advice. Rahkonen Jukka wrote: If it does not matter to use some other tool than OGR, OpenJUMP can explode multifeatures and geometry collections. My goal is to make this transformation in Python, and I did not want to write either unnecessary

Re: [gdal-dev] Re: Multipart to singlepart

2010-12-09 Thread Paolo Corti
My goal is to make this transformation in Python, and I did not want to write either unnecessary code or complicated code (for me). If I have a solid and interesting result, I will publish it here. Ciao Andrea this code will do the trick (note that it will create a polygon for each ring, so

[gdal-dev] Re: Multipart to singlepart

2010-12-09 Thread iomeneandrei
Caro Paolo, Paolo Corti wrote: Ciao Andrea this code will do the trick (note that it will create a polygon for each ring, so you will get a polygon for each hole as well) [...] writing in groups like this is always a surprise and a great pleasure. Thank you, thank you, thank you. I have

Re: [gdal-dev] Re: Multipart to singlepart

2010-12-09 Thread Even Rouault
I have modified a little your code - https://gist.github.com/735330 - and I have this message: Polygon added. Traceback (most recent call last): File PaoloIsGreat.py , line 32, in module multipoly2poly(in_lyr, out_lyr) File PaoloIsGreat.py , line 8, in multipoly2poly for geom_part in

[gdal-dev] Re: Multipart to singlepart

2010-12-09 Thread iomeneandrei
Hi Even, Even Rouault wrote: Geometry have been made iterable only since GDAL 1.7.0. You need to upgrade your GDAL version or modify a bit the script to make the iteration with the OGR API. instead of : for geom_part in geom: addPolygon(geom_part.ExportToWkb(), out_lyr)

Re: [gdal-dev] Re: Multipart to singlepart

2010-12-09 Thread Sebastian E. Ovide
Hi Andrea, Just a note of warning: if you have a point x,y that is inside the hole (so it doesn't belong the the polygon), and you run some point in polygon query (intersection for example) you will get that it is no part of any polygon but if you convert the ring in two polygons using this

[gdal-dev] Re: Multipart to singlepart

2010-12-07 Thread iomeneandrei
Hi Frank, Frank Warmerdam wrote: Reviewing the ogr2ogr code I see this does trigger a call to forceToPolygon() though *mostly* it exists to set the type of the created layer. So, yes, -nlt polygon with ogr2ogr may well do what you want. I have used this GML file as input:

Re: [gdal-dev] Re: Multipart to singlepart

2010-12-07 Thread Frank Warmerdam
On 10-12-07 03:43 AM, iomeneandrei wrote: Hi Frank, Frank Warmerdam wrote: Reviewing the ogr2ogr code I see this does trigger a call to forceToPolygon() though *mostly* it exists to set the type of the created layer. So, yes, -nlt polygon with ogr2ogr may well do what you want. I have

[gdal-dev] Re: Multipart to singlepart

2010-12-07 Thread iomeneandrei
Dear Frank, Frank Warmerdam wrote: I tried it with a trunk build and the multipolygon is converted to a polygon. I suspect the feature of the forcing support is new and if you want it you would need a reasonably recent development build - more recent than FWTools. I have downloaded

Re: [gdal-dev] Re: Multipart to singlepart

2010-12-07 Thread Frank Warmerdam
On 10-12-07 02:48 PM, iomeneandrei wrote: I have downloaded GDAL 1.7.3 from here http://vbkto.dyndns.org/sdk/, and I have made a test. The output file now does not contain ever MultiPolygon, but it has only Polygon. And I have made this test using two output formats: SQLite and GML. This is a

[gdal-dev] Re: Multipart to singlepart

2010-12-06 Thread iomeneandrei
Hi Frank, Frank Warmerdam wrote: At the API or scripting level there is the OGRGeometryFactory::forceToPolygon() method to try and convert a multipolygon to a simple polygon. I will try using OGR API. I will be slow, but I hope I'll be able to do it. Thank you very much, a -

[gdal-dev] Re: Multipart to singlepart

2010-12-06 Thread iomeneandrei
Hi Frank, Frank Warmerdam wrote: I am not aware of a way to do this from the commandline utilities. could I use the -nlt parameter of ogr2ogr and force POLYGON? If no, what's the power of -nlt parameter? Once again, thank you, a - Andrea Borruso

Re: [gdal-dev] Re: Multipart to singlepart

2010-12-06 Thread Frank Warmerdam
On 10-12-06 06:13 PM, iomeneandrei wrote: Hi Frank, Frank Warmerdam wrote: I am not aware of a way to do this from the commandline utilities. could I use the -nlt parameter of ogr2ogr and force POLYGON? If no, what's the power of -nlt parameter? Andrea, Reviewing the ogr2ogr code I see