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.

Background

We have a GeoServer layer backed by a PostGIS table with 22 million smallish features covering the continental US. We're using GeoServer to serve the features as a WMS layer to a client application that is only interested in the data at large scales (close-up). To avoid running queries that return millions of features, I've used a style that shuts off display of all features at smaller scales. This gets the job done, but it's annoying not to be able to get a preview of a larger area (e.g. in GeoServer's OpenLayers layer preview).

Question

Is there some easy way to tell GeoServer, "at small scales, just draw some features"? I'm not really picky about which features so long as the map generally appears to have data wherever we have data. A random subset of them would be fine so long as it was "spatially random" (if that makes sense).

share|improve this question
    
If you used WFS, you could limit the number of returned features - request GetFeature - using the parameter maxFeatures. However there is no guarantee that the returned features are uniformly or randomly distributed in the space. –  dariapra Nov 30 '12 at 16:10
    
True, and that might be good enough, but the client is pretty "dumb" (just a Silverlight app that knows the BBOX and image size). Making it understand WFS is probably out of scope, especially since things basically work and this is more about getting a quick preview outside our app. –  adv12 Nov 30 '12 at 16:15
    
Could you duplicate the layer, generalize, and then serve the generalized form in the preview? Possible even aggregate to show density of features? –  Jay Laura Nov 30 '12 at 17:50
    
I suppose that's possible, but I think I'm mostly interested in something that could be done with a single layer within GeoServer, partly because the primary motivation for the question at the moment is a desire to quickly, visually evaluate our loading process. (We exported to a pile of shapefiles by state/UTM zone from ArcMap, then loaded those into PostGIS, and apparently we missed some.) Generation of additional layers compounds the checking problem, as it introduces new opportunity for errors. –  adv12 Nov 30 '12 at 19:36
add comment

1 Answer

  • Create a "SQL view" layer in GeoServer with something like this: SELECT * FROM yourpostgistable ORDER BY RANDOM() LIMIT 100; this will be your smallscale layer.

  • Create a new style for smallscale layer, filtered by scale (ie 1:10.000.000): <sld:MinScaleDenominator>1.0E7</sld:MinScaleDenominator>

  • Create a new style for your largescale layer, filtered by scale: <sld:MaxScaleDenominator>1.0E7</sld:MaxScaleDenominator>

  • Create a "Layer Group" in GeoServer adding smallscale and largescale layers

share|improve this answer
add comment

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.