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.

As a followup to this question, I downloaded the vector data here:

and I successfully created the rasterized water/land mask I wanted:

However, there are too many rivers at this level.

Question

Can I/how do I make use of the scale information in the 10m_rivers_lake_centerlines_scale_ranks.dbf file?

Details

(Part of this dataset)

Note I can open the .dbf file in a text editor and see loads of interesting and hopefully useful data:

...
River              0.300000012
River              Pivd. Buh     8       670670
River              0.349999994
River              Pivd. Buh     8       670670
River              0.200000003
Lake Centerline    Klarlven      8       677677
Lake Centerline    0.250000000
Lake Centerline    Klarlven      
...

(this is a random chunk of binary formatted by removing spaces and adding newlines)

Using Nik2Img.py I run the following XML and get the overrun-with-rivers-results:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map bgcolor="black" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over">

  <Style name="landstyle">
    <Rule>
      <LineSymbolizer>
        <CssParameter name="stroke">white</CssParameter>
        <CssParameter name="stroke-width">0.0</CssParameter>
      </LineSymbolizer>

      <PolygonSymbolizer>
        <CssParameter name="fill">white</CssParameter>
        <CssParameter name="gamma">0.65</CssParameter>
      </PolygonSymbolizer>
    </Rule>
  </Style>

  <Style name="waterstyle">
    <Rule>
      <LineSymbolizer>
        <CssParameter name="stroke">black</CssParameter>
        <CssParameter name="stroke-width">0.0</CssParameter>
      </LineSymbolizer>

      <PolygonSymbolizer>
        <CssParameter name="fill">black</CssParameter>
        <CssParameter name="gamma">0.8</CssParameter>
      </PolygonSymbolizer>
    </Rule>
  </Style>

  <Style name="riverstyle">
    <Rule>    
      <LineSymbolizer>
        <CssParameter name="stroke">black</CssParameter>
        <CssParameter name="stroke-width">0.15</CssParameter>
      </LineSymbolizer>

      <PolygonSymbolizer>
        <CssParameter name="fill-opacity">0</CssParameter>
        <CssParameter name="fill">black</CssParameter>
      </PolygonSymbolizer>
    </Rule>
  </Style>

  <Layer name="world" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>landstyle</StyleName>
    <Datasource>
      <Parameter name="type">shape</Parameter>
      <Parameter name="file">../10m/10m_land</Parameter>
    </Datasource>
  </Layer>

  <Layer name="world" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>landstyle</StyleName>
    <Datasource>
      <Parameter name="type">shape</Parameter>
      <Parameter name="file">../10m/10m_minor_islands</Parameter>
    </Datasource>
  </Layer>


<!--
  <Layer name="world" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>waterstyle</StyleName>
    <Datasource>
      <Parameter name="type">shape</Parameter>
      <Parameter name="file">../10m/10m_lakes</Parameter>
    </Datasource>
  </Layer>
-->

  <Layer name="world" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>riverstyle</StyleName>
    <Datasource>
      <Parameter name="type">shape</Parameter>
      <Parameter name="file">../10m/10m_rivers_lake_centerlines_scale_ranks</Parameter>
    </Datasource>
  </Layer>

</Map>

Changing the appropriate riverstyle section to the following eliminates all rivers/lake centerlines instead of filtering anything by type (River vs. Lake Centerline) or scale/rank/thickness:

  <Style name="riverstyle">
    <Rule>
      <Filter>[River] &gt;= 0</Filter>

      <LineSymbolizer>
        <CssParameter name="stroke">black</CssParameter>
        <CssParameter name="stroke-width">0.15</CssParameter>
      </LineSymbolizer>

      <PolygonSymbolizer>
        <CssParameter name="fill-opacity">0</CssParameter>
        <CssParameter name="fill">black</CssParameter>
      </PolygonSymbolizer>
    </Rule>
  </Style>

How do I/can I make some filter(s) for this?

      <Filter>[River] &gt;= 0</Filter>
      <Filter>[River] &gt; 0</Filter>

I'm new to Mapnik and Natural Earth Shapefiles. I'm an experienced programmer so I'm willing to write code (Python, C#, etc.) if I need to but I'd like to use the tools available if possible.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

The attribute 'River' does not exist in that shapefile as far as I can tell. Your post helped remind me that Mapnik should be throwing an error in this case, so it is easier to catch common typo's like this (http://trac.mapnik.org/ticket/604).

A trick to get the attribute names is to open the Shapefile in QuantumGIS (and even use the Quantumnik Plugin if you want an xml snippet generated for Mapnik) or use ogr2ogr to query the shapefile like:

$ ogrinfo 10m_rivers_lake_centerlines_scale_ranks.shp -so -al
INFO: Open of `10m_rivers_lake_centerlines_scale_ranks.shp'
      using driver `ESRI Shapefile' successful.

Layer name: 10m_rivers_lake_centerlines_scale_ranks
Geometry: Line String
Feature Count: 4078
Extent: (-164.903495, -52.157769) - (177.211192, 75.793463)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_1984",6378137.0,298.257223563]],
    PRIMEM["Greenwich",0.0],
    UNIT["Degree",0.0174532925199433]]
StrokeWeig: Real (19.9)
FeatureCla: String (32.0)
Name1: String (254.0)
Name2: String (254.0)
ScaleRank: Integer (10.0)
RiverNum: Integer (10.0)
Dissolve: String (100.0)
Note: String (50.0)
share|improve this answer
    
Great! I actually just got this working when I went offline: I just opened the .dbf file with emacs and looked at the various English language strings. When I tried <Filter>([ScaleRank] &lt;= 4)</Filter> it works perfectly. But the summary of the columns is excellent. I think I will write multiple filters based on StrokeWeig and FeatureCla to get the look I want at various zoom levels. Thanks. –  Jared Updike Sep 14 '10 at 18:37

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.