Problem with projection importing shapefile

43 views
Skip to first unread message

Daniel de la Cuesta

unread,
Jun 9, 2011, 11:12:13 AM6/9/11
to geodjango
Hi,

I am using the import utility to import a shapefile layer

layer = LayerMapping(Distritos,
POSTAL_SHP,
mapping,
transform=True,
encoding='iso-8859-1')

the shapefile has this prj file:

PROJCS["ED_1950_UTM_Zone_30N",GEOGCS["GCS_European_1950",DATUM["D_European_1950",SPHEROID["International_1924",
6378388.0,297.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",
0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",
500000.0],PARAMETER["False_Northing",
0.0],PARAMETER["Central_Meridian",-3.0],PARAMETER["Scale_Factor",
0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

The utility "prj2espg" (http://prj2epsg.org/search) says it is a 23030
srid

I define my geometry field with this SRID:

geometry = models.MultiPolygonField(_('Poligono'),srid=23030)

The problem is that the geometry doesn't fits with my Google Maps base
layer, you can see and example here (take a look at the coastline):
http://dl.dropbox.com/u/731130/selection.png

Any idea?

larry price

unread,
Jun 9, 2011, 12:29:00 PM6/9/11
to geod...@googlegroups.com

It's probably easiest to deal with this in the database (assuming you
are using Postgres + PostGIS)

using polygon_table as the name of the table you are altering

sql code
"""

alter table polygon_table drop constraint "enforce_srid_the_geom";

update polygon_table set the_geom=st_transform(the_geom,4269);

alter table polygon_table add constraint "enforce_srid_the_geom" check
(st_srid(the_geom)=4269);

"""

If you get an error about being unable to perform the transform you
may want to manually set the srid with

select updategeometrysrid('polygon_table','the_geom',23030);

and then redo the reprojection.

Hope that helps.

Reply all
Reply to author
Forward
0 new messages