views:

133

answers:

1

Hi,

I'm importing shapefiles into a Postgres+PostGIS database.

Here's my usual procedure:
* Find an srid in the spatial_ref_sys table where srtext appears to match the shapefile's .prj file
* Upload the data into a new table using the shp2pgsql utility, specifying the srid using the -s flag
* Add the new table to my main geometry table, and on the way convert to an srid of 4269 (the Census standard projection) using ST_Transform

Unfortunately, the spatial_ref_sys table doesn't include Mississippi state's standard projection. The contents of their .prj file is as follows, where I've bolded the parts I usually try to match:

PROJCS["mstm",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",1300000.0],PARAMETER["Central_Meridian",-89.75],PARAMETER["Scale_Factor",0.9998335],PARAMETER["Latitude_Of_Origin",32.5],UNIT["Meter",1.0]]

I eventually found the ogr2ogr utility, and especially with the "peace and joy" promises, I decided to give it a try. I tried this command:

ogr2ogr -update -f "PostgreSQL" PG:"Connection details" 
    "File name.shp" -t_srs EPSG:4269 -nln Table_Name

I am now getting the error "Terminating translation prematurely after failed translation of layer" -- which seems to indicate that ogr2ogr is not going to be the savior I imagined in getting arbitrary .prj files neatly into the 4269 projection.

Any ideas about what to do?

+3  A: 

Here it is on spatialreference.org

http://spatialreference.org/ref/epsg/3814/

You just need to use epsg 3814. I highly reccomend spatialreference.org for finding SRIDs

TheSteve0
This is a great start. But the link you reference does not include a proj4 reference - either as its "proj4" link or in its "PostGIS spatial_ref_sys INSERT statement" link. Without the proj4, I get an error `AddToPROJ4SRSCache: couldn't parse proj4 string: '': (null)` when I try to use ST_Transform.
Summer
but you don't need any of that - when you import it this time you can say the SRID (which is the same as the EPSG) is 3814. Then you are all set
TheSteve0
That's what I did. I imported, and said the SRID was 3814 - no problem. But when I tried to convert the data to SRID 4269 using ST_Transform, I couldn't do it. :(
Summer
what is the error?
TheSteve0
Thanks --a lot-- for your continued help. The error is `ERROR: AddToPROJ4SRSCache: couldn't parse proj4 string: '': (null)` and it occurs in an insert query where I call ST_Transform(the_geom,4269). I believe the error is because the PostgreSQL insert string for srid 3814 does not include a proj4 string -- and perhaps the ST_Transform function relies on it.
Summer
Can you just go ahead and paste an example SQL statement here. I think that would make it easier for me to decipher your error message
TheSteve0
`INSERT INTO districts (id, state, geom_id, geom_name, lsad_id, lsad_name, the_geom) SELECT gid+130000, 'MS', annonum, 'Mississippi Appeals Court District '||annonum, 'IE', '', ST_Transform(the_geom,4269) from ms_appeals`
Summer
There is a proj4 string in postgis"+proj=tmerc +lat_0=32.5 +lon_0=-89.75 +k=0.9998335 +x_0=500000 +y_0=1300000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs "I am concerned about your unquoted - annonum for geom_idandyou don't have as many inputs as you have defined fields. Your St_transform seems to line up with lsad_name.I am not sure if those are the problems but nothing is wrong in postgis from what I can tell.
TheSteve0