Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to run the following query to determine the area and number of points of a polygon:

Select osm_id, st_npoints(the_geom) as numPoints, st_area(transform(the_geom, 3395))/1000000 as areakm2 from water_table where st_isvalid(the_geom);

I receive the following error:

Input geometry has unknown (-1) SRID

Anyone know what the problem is?

share|improve this question
    
is your database a valid postgis one? I.e. did you specify the projection of the data if you loaded it via shp2pgsql or shp2pgsql-gui?.. Or, if you created the geometry with an existing column, did you use AddGeometryColumn with a valid spatial reference? –  Stev_k Nov 10 '11 at 16:55
    
I think PostGIS would complain with a different error if there wasn't a geometry column at all, so it looks like it was just imported without a specific SRID. –  MerseyViking Nov 10 '11 at 17:41

1 Answer 1

up vote 8 down vote accepted

For transform() (and many other PostGIS functions) to work, it needs to know the CRS the source is in, as well as the CRS you want to transform it into. It looks like your geometry doesn't have an SRID associated with it (or rather the "unknown" SRID), so transform() can't do its job.

To give your geometry column a proper place in the world, you can change its SRID using UpdateGeometrySRID() For OSM, the SRID is now 3857.

share|improve this answer
    
Thanks. How is UpdateGeometrySRID used though? I've tried the following 'select UpdateGeometrySRID (water_table, the_geom, 3857)' This gives the following error: 'column water_table does not exist' –  nix Nov 10 '11 at 17:12
2  
If your table is in the public schema, then select UpdateGeometrySRID('water_table', 'the_geom', 3857); should work (note the quotes around the table and column names). Otherwise you will need to give it the schema name as an additional parameter at the start. –  MerseyViking Nov 10 '11 at 17:39
    
Thanks. That works :) I should've thought of the single quotes! –  nix Nov 10 '11 at 17:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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