[gdal-dev] problem with importing gml file to PostGIS with ogr2ogr
Piotr Pachół
piotrpachol at gmail.com
Tue Aug 6 14:32:26 PDT 2013
I have older configuration:
- PostgreSQL 9.1.5, compiled by Visual C++ build 1500, on Windows XP 32bit
- PostGIS 2.0.1
- gdal, geos and proj based on FWTools 2.4.7 for Windows 32bit
Should I install newer versions ?
What can I do with your script ?
I made additional test importing gml to shp (in shp everything is OK)
and than by PostGIS shapefile loader I imported shape to PostGIS.
The results are the same - some records have geometry the other not.
Perhaps I must ask on PostGIS forum ?
Piotr
W dniu 2013-08-06 09:18, Even Rouault pisze:
> Selon Piotr Pachó <piotrpachol at gmail.com>:
>
>> Thanks for your explanations but I still can't import polygons which
>> contains many vertices.
>> I do some test with polygons which contains different quantities of
>> vertices and
>> on my computer and configuration I can import polygon which has 2046
>> pairs (x,y) of coordinates
>> but I can't import when it has 2047 pairs and more.
>> The length of hex string which is created in attribute
>> geometry(Geometry,2180)
>> can't be longer than 65534 chars.
>> Where eventually to change some configurations variables of PostGIS or
>> Postgres or ogr2ogr ?
>> Do you have any other suggestion ?
> I don't reproduce such limitations with the following script :
>
> from osgeo import ogr
>
> ls = 'LINESTRING('
> for i in range(60000):
> if i != 0:
> ls = ls + ','
> ls = ls + "%d %d" % (2*i,2*i+1)
> ls = ls + ')'
>
> ds = ogr.Open('pg:dbname=autotest', update=1)
> lyr = ds.CreateLayer('biggeom', geom_type = ogr.wkbLineString, options =
> ['OVERWRITE=YES'])
> feat = ogr.Feature(lyr.GetLayerDefn())
> feat.SetGeometry(ogr.CreateGeometryFromWkt(ls))
> lyr.CreateFeature(feat)
> feat = None
> ds = None
>
> ds = ogr.Open('pg:dbname=autotest')
> lyr = ds.GetLayerByName('biggeom')
> lyr.ResetReading()
> feat = lyr.GetNextFeature()
> feat.DumpReadable()
>
>
> My config :
> POSTGIS="2.0.3 r11128" GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 4.8.0, 6 March 2012"
> GDAL="GDAL 1.10.0, released 2013/04/24" LIBXML="2.8.0" LIBJSON="UNKNOWN" RASTER
>
> PostgreSQL 9.1.9 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro
> 4.6.3-1ubuntu5) 4.6.3, 64-bit
>
>
>
>> Piotr
>>
>>
>> W dniu 2013-08-05 22:19, Even Rouault pisze:
>>> Selon Piotr Pachó <piotrpachol at gmail.com>:
>>>
>>>> Hello list,
>>>> I have problem with importing gml file (with polygons) to postgis using
>>>> standard ogr2ogr command which look like:
>>>>
>>>> ogr2ogr -a_srs EPSG:2180 -f "PostgreSQL" PG:"host=localhost
>>>> user=postgres dbname=test password=postgres port=5432"
>>>> d:\test\BDOT10k\OT_ADJA_A.xml
>>>>
>>>> I tried to import two GML files (with xsd schema necessary):
>>>> - OT_ADJA_A.xml - is orginal valid xml file - after import to Postgis a
>>>> table is created but geometry column is empty,
>>>> - OT_ADJA_A_changed.xml - is changed and not valid xml file - but after
>>>> import to Postgis a table is created and some records have geometry, the
>>>> other not.
>>>>
>>>> All files are accessible here:
>>>>
> https://drive.google.com/folderview?id=0B54CPoAEcivYOTZhNDlpU3hkTlk&usp=sharing
>>>> So I have the following questions:
>>>> 1. In file OT_ADJA_A.xml Why aplication not recognize <ot:geometria>
>>>> element which is "gml:PolygonType" type ? (there is definition in
>>>> OT_BDOT10k_BDOO.xsd file)
>>> Because the OGR GML driver has limited support to parse .xsd files. The
>> .xsd
>>> should be just near the .xml file, and with the same basename. But even if
>> it
>>> was the case, it is just not smart enough to realize that <ot:geometria>
>> must be
>>> a "gml:PolygonType"
>>>
>>>> 2. In file OT_ADJA_A_changed.xml I replace <ot:geometria> with
>>>> <gml:Polygon>. Why in that case some of records are imported with
>>>> geometry and the other not ?
>>> I don't see that problem. In the sample you've provided, there are 6
>> features
>>> with geometries and the 6 are imported into PostGIS with their geometries
>>>
>>>> 3. Is there any constraints of Postgis or ogr2ogr in quantity of
>>>> vertices which can have a Polygon ?
>>> No, you're only limited by the size of virtual memory (and possibly a
>> PostgreSQL
>>> limit on the size of records or fields)
>>>
>>>> I will appreciate any help.
>>>> Regards,
>>>> Piotr
>>>> _______________________________________________
>>>> gdal-dev mailing list
>>>> gdal-dev at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>>>
More information about the gdal-dev
mailing list