Opened 14 years ago

Closed 14 years ago

#478 closed defect (fixed)

[wktraster] There seems to be an offset in ST_Envelope or ST_Box2D

Reported by: robe Owned by: pracine
Priority: medium Milestone: WKTRaster 0.1.6
Component: raster Version: master
Keywords: Cc:

Description

I apologize if this isn't a bug. Could be just something about OpenJump.

This may be our misunderstanding of how this is supposed to work, but we imported a fairly random image into WKT Raster and when we look at the ST_Envelope and original image in OpenJump, they don't seem to line up.

This isn't a georeferenced image.

So here is command we used to generate the sql

python gdal2wktraster.py -r wonderpostgis_banner.png -t wonderpostgis -o wonderpostgis.sql

See attached the original image, the sql and the resulting openjump snapshot

Attachments (5)

wonder_with_envelop.png (109.3 KB ) - added by robe 14 years ago.
open jump result
wonderpostgis_banner.png (152.0 KB ) - added by robe 14 years ago.
original file imported
wonderpostgis.sql (820.7 KB ) - added by robe 14 years ago.
sql file loaded
demfile_envelope_wkb_format.txt (186 bytes ) - added by jorgearevalo 14 years ago.
DEM file envelope
wondergis_envelope_wkb_format.txt (186 bytes ) - added by jorgearevalo 14 years ago.
Wondergis envelope

Download all attachments as: .zip

Change History (20)

by robe, 14 years ago

Attachment: wonder_with_envelop.png added

open jump result

by robe, 14 years ago

Attachment: wonderpostgis_banner.png added

original file imported

by robe, 14 years ago

Attachment: wonderpostgis.sql added

sql file loaded

comment:1 by pracine, 14 years ago

Component: postgiswktraster
Owner: changed from pramsey to pracine
Summary: There seems to be an offset in ST_Envelope or ST_Box2D[wktraster] There seems to be an offset in ST_Envelope or ST_Box2D
Version: 1.5.Xtrunk

comment:2 by pracine, 14 years ago

This seems related to ticket 348.

comment:3 by jorgearevalo, 14 years ago

Hello,

I've made little modifications on core source. Could you please tell me how did you get the wonder_with_envelop.png image and the ST_Envelope result? I'm a begginer with OpenJump.

Thanks in advance

comment:4 by robe, 14 years ago

Jorge,

For to get that image in OpenJump 1) I used the File→open file and pointed at the wonderpostgis_banner.png image 2) Then I did an ad hoc query by going to Layer → Run Data Store Query (Create a postgis connection first)

Then type query

SELECT ST_AsBinary(ST_Envelope(rast))
FROM wonderpostgis;

Let me know if any of that is unclear.

comment:5 by robe, 14 years ago

Same issue with ST_ConvexHull by the way.

comment:6 by jorgearevalo, 14 years ago

Ok, I suppose I need a plugin to load image files as datasets, because I only can open shapefiles. Which plugin are you using? I'm following this: http://sourceforge.net/apps/mediawiki/jump-pilot/index.php?title=Plugins_for_OpenJUMP#II_-_Raster_Image_Plugins

comment:7 by pracine, 14 years ago

Jorge, we are not able to display raster right now, only the enveloppe, the box2d or (soon) the AsPolygon geometry versions of rasters. From OpenJump, you should be able to query PostGIS and fetch geometries. In the version I have, I have to convert every geometries to binary using AsBinary(the_geom).

comment:8 by robe, 14 years ago

Jorge,

Not sure Pierre answered your question. I didn't use any plugin for the image. Or at least I think it built into the core of OpenJump, but I do have a lot of plugins.

OpenJump allows you to overlay raster images on top of spatial data similar to QGIS.

So for the image part. 1) I did file→open file (in the file options I get tiff, jpg,png, jpeg as options and then picked the wonderpostgis_banner.png I had used to load my db with.

2) Then I used the Layer → Run Datastore Query — point at my PostGIS connection (instance is the database name)

SELECT ST_AsBinary(ST_Envelope(rast))
FROM wonderpostgis;

It still seems to sit above my picture using latest trunk. I tried the same thing in QGIS and does the same thing.

For QGIS since it doesn't support ad-hoc queries — I created a view and used the view. For raster layer — used Add Raster Layer option

CREATE OR REPLACE VIEW vwextent
AS
SELECT rid, ST_Envelope(rast) As geom
FROM wonderpostgis;

comment:9 by robe, 14 years ago

I wonder if its a problem with loading non-georeferenced data with the loader itself if I don't specify args.

I just tried loading up Mount St. Helens DEM Before earthquake and comparing and overlaying the original DEM and the envelope of my raster in QGIS, and that seems to overlay fine.

http://ned.usgs.gov/Ned/historic.asp

comment:10 by jorgearevalo, 14 years ago

Regina,

Sorry, I was using OpenJump from Ubuntu 9.10 repositories. That's the old 1.0 version. I've downloaded the last stable one (1.3.1), and now it's ok. I can see what you say.

About the loader, yes, you have to specify the srid as an argument. If not, -1 is used. In the DEM file, for example, the srid matching with

+proj=utm +zone=10 +ellps=clrk66 +datum=NAD27 +units=m +no_defs

should be used, but you get -1 if don't specify the right one with —srid option (I suppose you did it). This could be a new ticket, I guess…

comment:11 by robe, 14 years ago

Nope didn't specify srid of it or anything for that matter and it came in as -1 which was okay and expected, but it lined up okay regardless with the original DEM. Is it something to do with the fact that my random image was a PNG. Is it just difference in assumption in the loader for raster type if you don't explicitly give it arguments?

by jorgearevalo, 14 years ago

DEM file envelope

by jorgearevalo, 14 years ago

Wondergis envelope

comment:12 by jorgearevalo, 14 years ago

Mmmm… I see, but I don't know the reason. I've tested with more PNG and JPEG files ant the result is the same. I provide the envelope for both, the wondergis PNG file and the DEM file. I'll investigate this.

comment:13 by pracine, 14 years ago

I guess the clue here is the fact that ST_Box2D coordinates are encoded as float4 and Envelope as doubles. If I'm right, 1) the bug should appear only when there is many significant digits in the coordinates and 2) a PostGIS line geometry joining one of the two diagonals of a raster extent should present the same problem (Box2d should be different than the envelope). To verify…

comment:14 by robe, 14 years ago

I think the problem here might be that the PixelYSize is being set wrong. It should be negative instead of positive.

Remember I had posted an invalid bug #489 about why I'm getting negative pixel y sizes, and Mike Toews corrected me and said they usually are negative.

Well for the gif and png samples I loaded, I noticed the PixelYSize was coming in as 1 so I changed it to -1 and that made everything line up right.

comment:15 by pracine, 14 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.