Quantcast

[gdal-dev] Ogr2ogr, PostGIS and numeric field overflow with a shapefile

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[gdal-dev] Ogr2ogr, PostGIS and numeric field overflow with a shapefile

jratike80

Hi,

 

See this gis.stackexchange question https://gis.stackexchange.com/questions/240900/shp2pgsql-segmentation-fault.

 

I have confirmed that Europe_coastline.shp from this zip https://www.eea.europa.eu/data-and-maps/data/eea-coastline-for-analysis-1/gis-data/europe-coastline-shapefile/at_download/file can’t be saved into PostGIS with ogr2ogr.  The error message is exactly this

 

ERROR 1: COPY statement failed. ERROR:  numeric field overflow

DETAIL:  A field with precision 19, scale 11 must round to an absolute value less than 10^8.

CONTEXT:  COPY coastline, line 1, column shape_leng: "275736334.13200003000"

 

The error seems to happen in PostGIS which creates a field for “shape_leng” as NUMERIC(19,11) and then insertion of value 275736334.13200003000 fails. If GDAL user gets this kind of (invalid?) shapefile, what can they do? I had a try with –oo ADJUST_TYPE=YES but with no luck. Opening the shapefile and saving a copy with OpenJUMP indeed works because OpenJUMP is changing the field definition from Shape_Leng: Real (19.11) into Shape_Leng: Real (33.16).

 

-Jukka Rahkonen-

 

 


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ogr2ogr, PostGIS and numeric field overflow with a shapefile

Even Rouault-2

On vendredi 19 mai 2017 15:15:02 CEST Rahkonen Jukka (MML) wrote:

> Hi,

>

> See this gis.stackexchange question

> https://gis.stackexchange.com/questions/240900/shp2pgsql-segmentation-fault

> .

>

> I have confirmed that Europe_coastline.shp from this zip

> https://www.eea.europa.eu/data-and-maps/data/eea-coastline-for-analysis-1/g

> is-data/europe-coastline-shapefile/at_download/file can't be saved into

> PostGIS with ogr2ogr. The error message is exactly this

>

> ERROR 1: COPY statement failed. ERROR: numeric field overflow

> DETAIL: A field with precision 19, scale 11 must round to an absolute value

> less than 10^8. CONTEXT: COPY coastline, line 1, column shape_leng:

> "275736334.13200003000"

>

> The error seems to happen in PostGIS which creates a field for "shape_leng"

> as NUMERIC(19,11) and then insertion of value 275736334.13200003000 fails.

> If GDAL user gets this kind of (invalid?) shapefile, what can they do? I

> had a try with -oo ADJUST_TYPE=YES but with no luck. Opening the shapefile

> and saving a copy with OpenJUMP indeed works because OpenJUMP is changing

> the field definition from Shape_Leng: Real (19.11) into Shape_Leng: Real

> (33.16).

 

Use -lco PRECISION=NO (PostGIS driver option) to create the field as FLOAT8 instead.

 

>

> -Jukka Rahkonen-

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ogr2ogr, PostGIS and numeric field overflow with a shapefile

jratike80

Hi,

 

That’s it. I think I should have known to read carefully the PG driver manual http://www.gdal.org/drv_pg.html.

 

-Jukka-

 

Even Rouault wrote:

 

Re: [gdal-dev] Ogr2ogr, PostGIS and numeric field overflow with a shapefile

 

On vendredi 19 mai 2017 15:15:02 CEST Rahkonen Jukka (MML) wrote:

> Hi,

>

> See this gis.stackexchange question

> https://gis.stackexchange.com/questions/240900/shp2pgsql-segmentation-fault

> .

>

> I have confirmed that Europe_coastline.shp from this zip

> https://www.eea.europa.eu/data-and-maps/data/eea-coastline-for-analysis-1/g

> is-data/europe-coastline-shapefile/at_download/file can't be saved into

> PostGIS with ogr2ogr. The error message is exactly this

>

> ERROR 1: COPY statement failed. ERROR: numeric field overflow

> DETAIL: A field with precision 19, scale 11 must round to an absolute value

> less than 10^8. CONTEXT: COPY coastline, line 1, column shape_leng:

> "275736334.13200003000"

>

> The error seems to happen in PostGIS which creates a field for "shape_leng"

> as NUMERIC(19,11) and then insertion of value 275736334.13200003000 fails.

> If GDAL user gets this kind of (invalid?) shapefile, what can they do? I

> had a try with -oo ADJUST_TYPE=YES but with no luck. Opening the shapefile

> and saving a copy with OpenJUMP indeed works because OpenJUMP is changing

> the field definition from Shape_Leng: Real (19.11) into Shape_Leng: Real

> (33.16).

 

Use -lco PRECISION=NO (PostGIS driver option) to create the field as FLOAT8 instead.

 

>

> -Jukka Rahkonen-

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ogr2ogr, PostGIS and numeric field overflow with a shapefile

jratike80
In reply to this post by Even Rouault-2

Hmm, but how about other formats? Is there some general workaround? For example conversion into shapefiles fails because of this error while geopackage seems to be OK.

 

-Jukka-

 

 

Lähettäjä: Rahkonen Jukka (MML)
Lähetetty: 19. toukokuuta 2017 18:32
Vastaanottaja: 'Even Rouault' <[hidden email]>; [hidden email]
Aihe: Re: [gdal-dev] Ogr2ogr, PostGIS and numeric field overflow with a shapefile

 

Hi,

 

That’s it. I think I should have known to read carefully the PG driver manual http://www.gdal.org/drv_pg.html.

 

-Jukka-

 

Even Rouault wrote:

 

Re: [gdal-dev] Ogr2ogr, PostGIS and numeric field overflow with a shapefile

 

On vendredi 19 mai 2017 15:15:02 CEST Rahkonen Jukka (MML) wrote:

> Hi,

>

> See this gis.stackexchange question

> https://gis.stackexchange.com/questions/240900/shp2pgsql-segmentation-fault

> .

>

> I have confirmed that Europe_coastline.shp from this zip

> https://www.eea.europa.eu/data-and-maps/data/eea-coastline-for-analysis-1/g

> is-data/europe-coastline-shapefile/at_download/file can't be saved into

> PostGIS with ogr2ogr. The error message is exactly this

>

> ERROR 1: COPY statement failed. ERROR: numeric field overflow

> DETAIL: A field with precision 19, scale 11 must round to an absolute value

> less than 10^8. CONTEXT: COPY coastline, line 1, column shape_leng:

> "275736334.13200003000"

>

> The error seems to happen in PostGIS which creates a field for "shape_leng"

> as NUMERIC(19,11) and then insertion of value 275736334.13200003000 fails.

> If GDAL user gets this kind of (invalid?) shapefile, what can they do? I

> had a try with -oo ADJUST_TYPE=YES but with no luck. Opening the shapefile

> and saving a copy with OpenJUMP indeed works because OpenJUMP is changing

> the field definition from Shape_Leng: Real (19.11) into Shape_Leng: Real

> (33.16).

 

Use -lco PRECISION=NO (PostGIS driver option) to create the field as FLOAT8 instead.

 

>

> -Jukka Rahkonen-

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ogr2ogr, PostGIS and numeric field overflow with a shapefile

Even Rouault-2

On vendredi 19 mai 2017 15:54:03 CEST Rahkonen Jukka (MML) wrote:

> Hmm, but how about other formats? Is there some general workaround? For

> example conversion into shapefiles fails because of this error while

> geopackage seems to be OK.

 

ogr2ogr -unsetFieldWidth

 

 

>

> -Jukka-

>

>

> Lähettäjä: Rahkonen Jukka (MML)

> Lähetetty: 19. toukokuuta 2017 18:32

> Vastaanottaja: 'Even Rouault' <[hidden email]>;

> [hidden email] Aihe: Re: [gdal-dev] Ogr2ogr, PostGIS and numeric

> field overflow with a shapefile

>

> Hi,

>

> That's it. I think I should have known to read carefully the PG driver

> manual http://www.gdal.org/drv_pg.html.

>

> -Jukka-

>

> Even Rouault wrote:

>

> Re: [gdal-dev] Ogr2ogr, PostGIS and numeric field overflow with a shapefile

>

> On vendredi 19 mai 2017 15:15:02 CEST Rahkonen Jukka (MML) wrote:

> > Hi,

> >

> >

> >

> > See this gis.stackexchange question

> >

> > https://gis.stackexchange.com/questions/240900/shp2pgsql-segmentation-faul

> > t

> >

> > .

> >

> >

> >

> > I have confirmed that Europe_coastline.shp from this zip

> >

> > https://www.eea.europa.eu/data-and-maps/data/eea-coastline-for-analysis-1/

> > g

> >

> > is-data/europe-coastline-shapefile/at_download/file can't be saved into

> >

> > PostGIS with ogr2ogr. The error message is exactly this

> >

> >

> >

> > ERROR 1: COPY statement failed. ERROR: numeric field overflow

> >

> > DETAIL: A field with precision 19, scale 11 must round to an absolute

> > value

> >

> > less than 10^8. CONTEXT: COPY coastline, line 1, column shape_leng:

> >

> > "275736334.13200003000"

> >

> >

> >

> > The error seems to happen in PostGIS which creates a field for

> > "shape_leng"

> >

> > as NUMERIC(19,11) and then insertion of value 275736334.13200003000 fails.

> >

> > If GDAL user gets this kind of (invalid?) shapefile, what can they do? I

> >

> > had a try with -oo ADJUST_TYPE=YES but with no luck. Opening the shapefile

> >

> > and saving a copy with OpenJUMP indeed works because OpenJUMP is changing

> >

> > the field definition from Shape_Leng: Real (19.11) into Shape_Leng: Real

> >

> > (33.16).

>

> Use -lco PRECISION=NO (PostGIS driver option) to create the field as FLOAT8

> instead.

> > -Jukka Rahkonen-

>

> --

>

> Spatialys - Geospatial professional services

>

> http://www.spatialys.com

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Loading...