0

I use shp2pgsql to import an .shp ESRI shapefile into PostgreSQL database. I use brew installed shp2pgsql. I used this command first:

shp2pgsql -I -s 4326 /path/to/shape_file.shp public.os_gb | psql -U postgres -d postgres

It shows this message on terminal:

terminal output

It imports data into database but PostgreSQL Geometry Viewer says that it is not able to render "3D" shapes.

Then I tried this command:

shp2pgsql -I -t 2D -s 4326 /path/to/shape_file.shp public.os_gb | psql -U postgres -d postgres

Geometry Viewer shows 1 geom like this: Geometry Viewer shows 1 geom like this

So forcing in 2D did not work. Could you please help me with this and tell me what's wrong here.

Edit:

Here is the result of "ogrinfo -so -al my_shape_file.shp":

INFO: Open of `GB_GreenspaceSite.shp'
using driver `ESRI Shapefile' successful.

Layer name: GB_GreenspaceSite
Metadata:
  DBF_DATE_LAST_UPDATE=2018-09-24
Geometry: 3D Polygon
Feature Count: 143822
Extent: (9819.840000, 8274.570000) - (655230.650000, 1214133.190000)
Layer SRS WKT:
PROJCS["OSGB 1936 / British National Grid",
    GEOGCS["OSGB 1936",
        DATUM["OSGB_1936",
            SPHEROID["Airy 1830",6377563.396,299.3249646,
                AUTHORITY["EPSG","7001"]],
            TOWGS84[446.448,-125.157,542.06,0.15,0.247,0.842,-20.489],
            AUTHORITY["EPSG","6277"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4277"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",49],
    PARAMETER["central_meridian",-2],
    PARAMETER["scale_factor",0.9996012717],
    PARAMETER["false_easting",400000],
    PARAMETER["false_northing",-100000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","27700"]]
id: String (38.0)
function: String (40.0)
distName1: String (254.0)
distName2: String (254.0)
distName3: String (254.0)
distName4: String (254.0)
3
  • 1
    Welcome to GIS SE! As a new user, please be sure to take the tour to learn about this site's focused Q&A format.
    – Andy
    Dec 18, 2018 at 17:25
  • 1
    could you add the result of ogrinfo -so -al on the shapefile
    – Ian Turton
    Dec 18, 2018 at 18:06
  • Hi @IanTurton thanks for your answer. I edited and add the result of this command.
    – sinemy
    Dec 19, 2018 at 9:26

1 Answer 1

0

I suspect the issue is that your data is in EPSG:27700 (OSGB) rather than Lat/Lon (EPSG:4326). Since you only specify one projection in your -s shp2pgsql assumes it should set the geometries to be in that one. If you need to do a reproject while you are loading the data then you need to use -s 27700:4326.

1
  • Hello Ian, It worked thanks a lot! Thanks for very quick response!
    – sinemy
    Dec 19, 2018 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.