Opened 6 years ago
Closed 6 years ago
#3738 closed defect (fixed)
raster: Using -s without -Y in raster2pgsql transforms raster data instead of setting srid
|Reported by:||robe||Owned by:||robe|
Description (last modified by )
I haven't tested this myself, but on postgis users list, two people mentioned this behavior:
2017-04-11 14:25 GMT+02:00 Tumasgiu Rossini <rossini.t at gmail.com>: > Hi, > > I think I found the probelm, it is the -s option which make the sql > applying a st_transfrom on the raster to reproject it into the desired CRS > before inserting it in the table, thus creating an in-db raster. >
As Pierre noted, best thing to do is use the same reprojection syntax and shp2pgsql -s from_srid:to_srid (this might work already) have to test. and forbit transform with out-db. Since there is no point if its going to end up being in-db.
Change History (9)
comment:1 by , 6 years ago
|Summary:||Using -s and -R together transforms raster data instead of setting srid → Using -s and -R together in raster2pgsql transforms raster data instead of setting srid|
comment:2 by , 6 years ago
comment:3 by , 6 years ago
|Summary:||Using -s and -R together in raster2pgsql transforms raster data instead of setting srid → raster: Using -s and -R together in raster2pgsql transforms raster data instead of setting srid|
comment:4 by , 6 years ago
comment:5 by , 6 years ago
Okay this is clearly a bug and I think affects more than outdb. On some tests I did, it seems if you don't use -Y and you use -s, it attempts to do a ST_Transform.
If you use a -s without a -Y and happen to specify an srid that is different from the one it detected from the meta data of the raster, then it attempts to transform from the inferred srid to the new one.
So work around for out-of-db to get it to do the right thing is this:
raster2pgsql -C -t 500x500 -R -Y -s 26918 -F -I C:/gisdata/*.jp2 nj_aerials
— I had an aerial with no metadata for the srid (would normally come in as unknown), as long as I have a -Y in there it just does a setsrid. If I leave out the Y, I get an error on insert.
If I do in-db then the from_srid:to_srid seems broken. It's like it's traying to use the unknown srid as the from instead of what I specified.
anyway I have a patch for this. I plan to backport the part about -s srid doing a transform instead of set.
I think there are some loose ends with the ST_Transform logic, and since the transform feature was never announced, I may just keep that fix for 2.4 and just flag it as a new feature and keep the 2.3 transform logic broken.
comment:6 by , 6 years ago
|Summary:||raster: Using -s and -R together in raster2pgsql transforms raster data instead of setting srid → raster: Using -s without -Y in raster2pgsql transforms raster data instead of setting srid|
comment:7 by , 6 years ago
comment:8 by , 6 years ago
|Milestone:||PostGIS 2.4.0 → PostGIS 2.3.3|
comment:9 by , 6 years ago
|Status:||new → closed|
quick scan of raster2pgsql http://postgis.net/docs/doxygen/2.4/db/dd0/raster2pgsql_8c_source.html,
looks like we already support the -s srid_from:srid_to syntax for transformation.
Thought haven't verified it works and the documentation of it is commented out: